• Post Reply Bookmark Topic Watch Topic
  • New Topic

What's so special with " * "????

 
rob javier
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i passed as an argument the symbol " * ". but when i tried to print it, i got this:
arcldr.exe
arcsetup.exe
AUTOEXEC.BAT

btw, my code is as simple as this:
class Ops{
public static void main(String args[]){
System.out.println(args[0]);
System.out.println(args[1]);
System.out.println(args[2]);
}
}
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. This happens because the Operating System treats * as a wild character. Java can do nothing about it
If you want to pass * as a command line argument, enclose it in quotes
Example: java MyClass "*"
It will work for Windows.
I think it should work in UNIX also. If it doesn't work, try the escape characters
(Example: java MyClass \*)
 
rob javier
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to Java in General (Beginner) forum.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!