H
HugeBob
Hi All,
I'm studying for the SCJP 6 exam and I've run across an oddity.
Here's the code:
public class SwitchCheck {
public static void main(String [] args) {
final int a = 1, final int b = 2;
int x = 0;
switch (x) {
case a:
break;
case b:
break;
}
}
}
Why does this not work? Both a and b are final and receive their
value where they should. a and b are known at compile time. Yet I
get an error for the "case b:" statement.
I'm studying for the SCJP 6 exam and I've run across an oddity.
Here's the code:
public class SwitchCheck {
public static void main(String [] args) {
final int a = 1, final int b = 2;
int x = 0;
switch (x) {
case a:
break;
case b:
break;
}
}
}
Why does this not work? Both a and b are final and receive their
value where they should. a and b are known at compile time. Yet I
get an error for the "case b:" statement.