Scanner in = new Scanner(System.in);
int number = in.nextInt();
switch(number){
case 1:System.out.println("happy");
case 2:System.out.println("today");
case 3:System.out.println("is years");break;
default:System.out.println("hahaha");
上图是语句,执行的时候会从number开始一直执行遇到break时,执行才会结束。
如果case里没有number的选项,则会选择执行default