Switch Statement with Strings in Java

2014/10/05 11:47
阅读数 18
public static void main(String[] args) {

    String current = args[0];
    Days currentDay = Days.valueOf(current.toUpperCase());

    switch (currentDay) {
        case MONDAY:
        case TEUSDAY:
        case WEDNESDAY:
            System.out.println("boring");
            break;
        case THURSDAY:
            System.out.println("getting better");
             case FRIDAY:
        case SATURDAY:
        case SUNDAY:
            System.out.println("much better");
            break;

    }
}

public enum Days {

    MONDAY,
    TEUSDAY,
    WEDNESDAY,
    THURSDAY,
    FRIDAY,
    SATURDAY,
    SUNDAY
}

}
 
展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部