1. class Test {
public static void main(String[] args) {
int x = 3;
int y = 5;
switch (x) {
default;
y++;
break;
case 4:
y++;
case 5;
y++;
}
System.out.println("y =" + y);
}
}
2.class Test {
public static void main(String[] args) {
int x = 3;
int y =5;
switch (x) {
default;
y++;
case 4:
y++;
case 5;
y++;
}
System.out.println("y =" + y);
}
}
为什么输出结果y的值不一样? |
|