Trent
Trent

Reputation: 5

Why is the program referencing the first file in the same directory, when I type "java char *"?

public class Char
{

    public static void main(String[] args) {
        String plainText = args[0];

        char [] a = plainText.toCharArray();

        System.out.println(a);
    }

}

Upvotes: 0

Views: 37

Answers (1)

LexLythius
LexLythius

Reputation: 1944

This is really a Unix CLI question.

The problem is that the wildcard (*) character gets expanded (globbed) to all the entries in the directory prior to being fed to java, i.e., it's translated to something like

java char BooleanLoop.java BooleanLoop.class etcetera etcetera

If you want to feed the * character to java, either wrap it in single quotes ' or escape it with a backslash .

java char '*'
java char \*

Upvotes: 3

Related Questions