jdk 7版本开始,在switch,,.case 中才支持字符串格式,在此之前的版本只能是整型或者可以转换为整型的数值类型,比如byte、short、int、char、还有枚举.
public int simpleSwitch(String stringOne) {
switch (stringOne) {
case "a":
return 0;
case "b":
return 2;
case "c":
return 3;
default:
return 4;
}
}