public class TestSwitch {
public static void main(String[] args) {
char x='a';
switch(x){
case 'a':
case 'b': System.out.println("b");
case 'c': System.out.println("c");break;不需要{}
case 'd': System.out.println("d");
default:
System.out.println("end");不需要break
}
}
}
b
c
直到遇到break
本文通过一个Java程序示例展示了如何使用switch语句进行字符条件判断,并解释了break的作用。
356

被折叠的 条评论
为什么被折叠?



