public static void test(){
int i = 5;
switch (i){
case 5:
System.out.println("是个5");
break;
case 10:
System.out.println("是个10");
break;
case 4:
System.out.println("是个4");
break;
default:
System.out.println("默认值");
break;
}
}
public static void test(){
int i = 11;
switch (i){
case 5:case 11:case 12:
System.out.println("是个5");
break;
case 10:
System.out.println("是个10");
break;
case 4:
System.out.println("是个4");
break;
default:
System.out.println("默认值");
break;
}
}
下面的方法结果会是什么呢?
public static void test(){
int i = 11;
switch (i){
case 5:case 11:case 12:
System.out.println("是个5");
case 10:
System.out.println("是个10");
break;
case 4:
System.out.println("是个4");
break;
default:
System.out.println("默认值");
break;
}
}
结果是:
是个5
是个10
下面的方法结果会是什么呢?
public static void test(){
int i = 10;
switch (i){
case 5:case 11:case 12:
System.out.println("是个5");
case 10:
System.out.println("是个10");
break;
case 4:
System.out.println("是个4");
break;
default:
System.out.println("默认值");
break;
}
}
结果是:
是个10
下面的方法结果会是什么呢?
public static void test(){
int i = 4;
switch (i){
case 5:
System.out.println("是个5");
break;
case 10:
System.out.println("是个10");
break;
case 4:
System.out.println("是个4");
default:
System.out.println("默认值");
break;
}
}
结果是:
是个4
默认值
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有