jdk7之前 switch支持的类型只有byte、short、char、int、integer、enum枚举类型,在JDK7后,支持string类型。
String str = "yes";
switch (str) {
case "yes":
System.out.println("yes");
break;
case "no":
System.out.println("no");
break;
case "china":
System.out.println("china");
break;
default:
System.out.println("default");
}