-4

java Application 23 * 2

public static void main(String[] args){

    System.out.println(args.length);
}

output: 7

why?

Filburt
  • 17,626
  • 12
  • 64
  • 115
Ajit Singh
  • 11
  • 2

1 Answers1

1

On Windows, you would get what you're expecting.

On Linux, the command shell is applying wildcard expansion, replacing the * with names of all the files in the current directory.

To prevent wildcard expansion, quote the parameter (from Stop shell wildcard character expansion?):

java Application 23 '*' 2
Community
  • 1
  • 1
Andreas
  • 154,647
  • 11
  • 152
  • 247
  • 1
    or possibly the OP wants java Application '23 * 2' - that is, a single argument to main – FredK Dec 16 '15 at 17:05