This is in chapter 4 page 309...
Given:
class Fork {
public static void main(
String[] args) {
if(args.length == 1 | args[1].equals("test")) {
System.out.println("test case");
} else {
System.out.println("production " + args[0]);
}
}
}
And the command-line invocation:
java Fork live2
What is the result?
the answer is compilation fails. the book states "Because the short circuit (||) is not used, both operands are evaluated. Since args[1] is past the args array bounds, an ArrayIndexOutOfBoundsException is thrown"
I just dont get that..."Fork" on the command line invocation shall be args[1], and java, lives are args[0] and [2] respectively.
wat's the trick here any masters?