switch语句中case的标签

  • 类型为char、byte、short、int的常量表达式
  • 字符串字面量
String input=......;
switch (input.toLowerCase()) {
    case "yes" :
     ......
     break;
    case "no";
     ......
     break;
     ......
}
  • 枚举常量
enum Size {SMALL, LARGE};
Size size=......;
switch (size){
  case SMALL://不需要使用Size.SMALL
   ......
   break;
   ......
}
原文地址:https://www.cnblogs.com/Russel/p/5944504.html