Strange behavior of Java argument*

I wrote this lesson:

public class ListArg {
    public static void main(String args[])
    {
        for(int i=0;i<args.length;i++)
        {
            System.out.println(args[i]);
        }
    }
}

javac ListArg. Java / / compile class

I compile the above class and run it as follows: Java listarg*

However, listarg displays the contents of the current directory on the console instead of "*"

Solution

Editor: it looks like I'm wrong. After all, it may be Java If you are using a UNIX shell, this may be the shell that executes "globbing" However, it seems to do the same thing on windows, which surprised me (because the windows command line does not perform wildcard by default)

Unfortunately, on windows, normal references seem to give you a reference parameter, that is, if you print args [0] already running

java ListArg '*'

It will include single quotes I'm investigating whether there is a way to disable it... Although it can run on a UNIX shell

Editor: Well... So far, there is no luck. There is only one star string in Windows:(

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>