Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java enum

package vn.viettuts.javaenum;
 
public class EnumExample5 {
    // define days of week
    enum Day {
        MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, 
        SATURDAY, SUNDAY
    }
 
    public static void main(String args[]) {
        Day day = Day.SUNDAY;
 
        switch (day) {
        case SUNDAY:
            System.out.println("sunday");
            break;
        case MONDAY:
            System.out.println("monday");
            break;
        default:
            System.out.println("other day");
        }
    }
}
Source by viettuts.vn #
 
PREVIOUS NEXT
Tagged: #java #enum
ADD COMMENT
Topic
Name
8+1 =