Yesterday, some one ask me Can we
use Java Enum in Switch case ? Obviously he was learning Enum and not aware
powerful Enum in Java is. Yes, You can use Enum in Switch case
statement in Java like int primitive. If you are familiar with enum int pattern,
where integers represent enum values prior to Java 5 then you already knows how
touse Switch case with Enum. Using Java
Enum in Switch case is pretty straightforward, Just use Enum reference variable
in Switch and Enum constants or instances in CASE statement. In this Java
tutorial we will see one example of How
to use Enum in Switch statement in Java. By the way Enum is feature rich in
can implement interface in Java, Enum can override
method in Java, Enum can have constructor
in Java and Enum is full functional Type like class or interface.
Programmers use Enum with different ways. One of the best example of Enum in
Java is replace enum int pattern and enum String pattern. You can
Enum to write Thread-safe Singleton in Java.