Java Developers
Group for Java developers and programmers. Ask questions and get answers related to Java programming
263 Members
Join this group to post and comment.
Archana Priyadarshini
Archana Priyadarshini
Computer Science
24 Jan 2019

Java enums

An enum is a special "class" that represents a group of constants (unchangeable variables, like final variables).

To create an enum, use the enum keyword (instead of class or interface), and separate the constants with a comma. The enum can be defined within or outside the class because it is similar to a class.

eg. public enum Season { WINTER, SPRING, SUMMER, FALL }

Java enums extend the java.lang.Enum class implicitly. Therefore, you cannot extend any other class in enum.I

In Java, enum is a keyword. Enum constructors are always private or default. Therefore, you cannot have public or protected constructors in an enum type.

AdhikariHarika Reshma
AdhikariHarika Reshma
Computer Science
2mos ago


Enum in java is a data type that contains fixed set of constants.It can be used for days of week,directions.The java enum constants are static and final implicitly.Java enums can be thought of as classes that have fixed set of constants.

1. Enum improves type safety.

2.It can be easily used in switch and can be traversed.

3.It can have fields,constructors and methods.

4.It may implement many interfaces but cannot extend any class because it internally extends enum class.