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;
   ......
}

 

posted @ 2016-10-10 08:45  派大东  阅读(1227)  评论(0编辑  收藏  举报