WHAT IS ENUM DATATYPE IN JAVA

Mayank Tripathi

Total Post:807

Points:4035
Posted by  Mayank Tripathi
Java 
 623  View(s)
Ratings:
Rate this:
  1. Mayank Tripathi

    Post:807

    Points:4035
    What is enum datatype in java

    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;
     }
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!