public class EnumExample { // Here we define the enum as a nested class within class EnumExample public enum WeekDay { // The values a variable of this type can adopt MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY; // We can even write a method for this enum class public WeekDay getNextWeekDay() { WeekDay result; // We can use enumerated types in switch statements switch (this) { case MONDAY: result = TUESDAY; break; case TUESDAY: result = WEDNESDAY; break; case WEDNESDAY: result = THURSDAY; break; case THURSDAY: result = FRIDAY; break; case FRIDAY: result = MONDAY; break; default: System.out.println("Ooops! fallen off the switch!"); result = MONDAY; } return result; } } public static void main(String[] args) { WeekDay today = WeekDay.TUESDAY; WeekDay myDayOff = WeekDay.WEDNESDAY; WeekDay tomorrow = today.getNextWeekDay(); // We can compare enumerated types if (tomorrow == myDayOff) { System.out.println("Hooray!"); } else { System.out.println("Boo hoo hoo!"); } } }