+ 2
Switch
why does it prints 3 instand of 1? int x = 0; int a = 2; switch(a); { case 1: ++x; case 2: ++x; case 3: ++x; default: ++x; } System.out.println(x);
1 ответ
+ 5
because there is no break statement.. the value of x will increase till the end unless it finds break or default: case..
now if u add case 4: ++x; case 5: ++x; and then default: case..
the output will be 5