Hi,
I just finished a Roundup session. Question #223 asks:
True or False. In a switch statement, the argument to the case label can be a var which can fit within an int.
Answer: False. The case argument must be either an int literal, or an int-compatible var which is a constant (i.e., static final).
I'm confused. The byte in this program is not a constant, but can fit within an int, and it works.
class Switch2 {
byte x = 0;
Switch2() {
switch(x) { }
}
public static void main(
String args[]) {
new Switch2();
}
}