Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java enum


package vn.viettuts.javaenum;
 
public class EnumExample5 {
    // define enum Season
    enum Season {
        SPRING(5), SUMMER(10), FALL(15), WINTER(20);
 
        private int value;
 
        private Season(int value) {
            this.value = value;
        }
    }
 
    public static void main(String args[]) {
        for (Season s : Season.values()) {
            System.out.println(s + " " + s.value);
        }
    }
}
Source by viettuts.vn #
 
PREVIOUS NEXT
Tagged: #java #enum
ADD COMMENT
Topic
Name
6+8 =