An enum is created using ‘enum‘ keyword in Java. When we define an enum, we are implicitly extending java.lang.Enum. The compiler converts our enum into a class which extends [...]
Even though enum is a class type, we do not use new keyword but create a variable just like a primitive type as follows. PizzaSize size; (Or) PizzaSize size = PizzaSize.LARGE; The main advantage [...]
We can use either == or equals() method to compare enum values. Example: Both the ‘if’ statements in the below code are equivalent. SIZE == LARGE SIZE EQUALS LARGE Pizza Size is LARGE