// demonstrates an enumerated type //enumerated type declaration creates a special kind of class //the enum constants are all objects of the class //Day is a class //Day.SUNDAY is an instance of the Day class public class eg18_EnumDemo { //Declare the Day enumerated type enum Day {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY} public static void main(String[] args) { Day workDay = Day.WEDNESDAY; System.out.println (workDay); //prints ordinal value for a "Day" System.out.println("The orginal value for " +Day.SUNDAY+" is "+Day.SUNDAY.ordinal()); System.out.println("The orginal value for " +Day.SATURDAY+" is "+Day.SATURDAY.ordinal()); //compare two enum constants if (Day.FRIDAY.compareTo(Day.MONDAY) > 0) System.out.println(Day.FRIDAY +" is greater than "+ Day.MONDAY); else System.out.println(Day.FRIDAY +" is NOT greater than "+ Day.MONDAY); } }