Lookin to the code below
public class CrazyJava {
public static void main(String[] args) {
String arg1 = args[0];
String arg2 = args[1];
String arg3 = args[2];
System.out.println(arg1+arg2+arg3);
}
}
Just taking 3 command line arguments and print the result of concatenation.
Ok, lets compile the code
javac CrazyJava
now run as
java CrazyJava1
This will throw AIOB (ArrayIndexOutofBound)exception..you are correct
Note it and then run i now as following
java CrazyJava *
Amazing :) it doesn't give any error / exception but it prints the file(s) names which are present in the current directory (from where you are running the java ...)
why java is not behaving crazy when the command line argument is *
Is it a bug in Java ? It can't be. There is something behind the scene.
cheers,
Rupali
public class CrazyJava {
public static void main(String[] args) {
String arg1 = args[0];
String arg2 = args[1];
String arg3 = args[2];
System.out.println(arg1+arg2+arg3);
}
}
Just taking 3 command line arguments and print the result of concatenation.
Ok, lets compile the code
javac CrazyJava
now run as
java CrazyJava1
This will throw AIOB (ArrayIndexOutofBound)exception..you are correct
Note it and then run i now as following
java CrazyJava *
Amazing :) it doesn't give any error / exception but it prints the file(s) names which are present in the current directory (from where you are running the java ...)
why java is not behaving crazy when the command line argument is *
Is it a bug in Java ? It can't be. There is something behind the scene.
cheers,
Rupali
No comments:
Post a Comment