Enum Data Type in Java
An ‘enum’ is a special “class” in java. This class available in java.lang package. Enumerated data types are used to represent a group of named constants in Java.
To create an enum, use the ‘enum’ keyword, separate the constants with a comma, and they should be in uppercase letters.
For Example 1 :-
enum Animal{ CAT, DOG, ELEPHANT }
Example 2:-
enum Day{ SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }
Get Thayana Selvaratnam’s stories in your inbox
Join Medium for free to get updates from this writer.
NODE :- enum data types can be declared outside a Class or inside a Class but not inside a Method, and also we can declare main() method inside enum.
- Declared outside a Class
2. Defined inside the class
3. Declare main() method inside enum
Thank you.









