I had this code showing up in my java course today and not even the professor could answer why this is working. I hope that one of you knows the answer and can give it to me.
With the commented part it is strangely working. If I comment the part of z=3 then it is not working. Can someone explain :D ? Thanks in advance!
public static void main(String[] args) {
int a = 2;
switch(a) {
case 1:
int z=6;
case 2:
//z=3;
System.out.println(z);
}