Enums introduced in Java 5.0 (Read: New features in Java 5.0) allows switching to be done based on the enums values. It is one of the greatest new features introduced from the version 5.0. Prior to Java 1.4, switch only worked with int, short, char, and byte values. However, since enums have a finite set of …
Enum
Adding methods to an Enum
Enums introduced in Java 5.0 are just compiled java classes with some extra behavior. So you can basically do whatever you can in a normal java class inside an enum as well. That includes adding methods , class level variables and constructors to an enum. Adding methods to an enum works just like adding methods …