Switch
package com.andy.base.Andy.operator.structure;
public class SwitchDemo01 {
public static void main(String[] args) {
//case穿透 //switch 匹配一个具体的值
char grade = 'C';
switch (grade ){
case 'A':
System.out.println("优秀");
break;
case 'B':
System.out.println("良好");
break;
case 'C':
System.out.println("及格");
break;
case 'D':
System.out.println("再接再厉");
break;
case 'E':
System.out.println("挂科");
break;
default:
System.out.println("未知等级");
}
}
}
package com.andy.base.Andy.operator.structure;
public class SwitchDemo02 {
public static void main(String[] args) {
//JDk7的新特性,表达式结果可以使字符串!!!
//字符的本质还是数字
//反编译 java---class(字节码文件)----反编译(IDEA)
String name = "钟健";
switch (name){
case "钟健":
System.out.println("钟健");
break;
case "Andy":
System.out.println("Andy");
break;
default:
System.out.println("弄啥咧!");
}
}
}
标签:case,System,break,Switch,println,public,out
From: https://www.cnblogs.com/zhongjianYuan/p/17143381.html