The following java code executes without error in Java 1.7
public static void main(String[] args) {
int x = 5;
switch(x) {
case 4:
int y = 3423432;
break;
case 5: {
y = 33;
}
}
}
How does java figure out that y is an int since the declaration never gets run. Does the declaration of variables within a case statement get scoped to the switch statement level when braces are not used in a case statement?