본문 바로가기

프로그래밍관련/java

A Switch on String for JAVA


A Switch on String for JAVA


 

public enum Day
{
    SUNDAY, MONDAY, TUESDAY, WEDNESDAY, 
    THURSDAY, FRIDAY, SATURDAY; 
}
switch (Day.valueOf(str))
{
    case SATURDAY:              
    case SUNDAY:
        // weekend processing ...
        break;
    default:
        // weekday processing ...
}
출처 : http://www.xefer.com/2006/12/switchonstring