switch(表达式){
case 表达1:
语句1:
break;
case 表达2:
语句2:
break;
……
default:
语句
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入你的年级");
int grade = sc.nextInt();
switch(grade){
case 1:
System.out.println("一年级");
break;
case 2:
System.out.println("二年级");
break;
case 3:
System.out.println("三年级");
break;
case 4:
System.out.println("四年级");
break;
default:
System.out.println("社会人");
}
}