Monday, 15 October 2007

ENUM example in JAVA

** ENUM Example

==== ENUM_Season.java =====
public enum ENUM_Season {
SPRING, SUMMER, FALL, WINTER
}


==== ENUM_Season01_A.java ===

public class ENUM_Season01_A {
public static void main(String[] args) {
ENUM_Season season = ENUM_Season.SUMMER;
System.out.println(season);
if (season.equals(ENUM_Season.SPRING) == true) {
System.out.println("the current season is SPRING.");
}else {
System.out.println("the current season is not SPRING.");
}
}
}

===== Output ===
SUMMER
the current season is not SPRING.

No comments: