switch
switch(111){
case '222':
//
break;
case '333':
//
break;
default:
//
}
package ds;
import java.util.Scanner;
public class Dome7 {
public static void main(String[] args) {
char grade = 'a';
switch (grade){
case 'a':
System.out.println("A级");
break;//break相当及时结束
case 'b':
System.out.println("B级");
break;
case 'C':
System.out.println("C级");
break;
default:
System.out.println("错误");
}
}
}
package ds;
import java.util.Scanner;
public class Dome7 {
public static void main(String[] args) {
String grade = "罗焕钊";
switch (grade){
case "罗焕钊":
System.out.println("罗焕钊是好人");
break;//break相当及时结束
case "":
System.out.println("B级");
break;
case "1":
System.out.println("C级");
break;
default:
System.out.println("错误");
}
}
}