Switch Statement with Strings in Java

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
}

}
 

你可能感兴趣的:(Switch Statement with Strings in Java)