Enum keyword is used to represent a fixed number of related values. Since enum constants are implicitly static and final,there values can't be changed once they are created.
public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY,THURSDAY, FRIDAY, SATURDAY } // Uses public void weekDay() { switch (day) { case MONDAY: System.out.println("Mondays are bad."); break; } }
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
public enum Day {SUNDAY, MONDAY, TUESDAY, WEDNESDAY,THURSDAY, FRIDAY, SATURDAY
}
// Uses
public void weekDay() {
switch (day) {
case MONDAY:
System.out.println("Mondays are bad.");
break;
}
}