Java Enum Example
In Java, instead of creating a bunch of constants you can make use of Enums which better helps group them. For example, you can create an Enum of Colors(RED, YELLOW, GREEN, BLUE).
Also they help make sure that the constant is not outside the ones defined in the Enum.
Declaring Enums:
Here's how you declare Enums in Java.
Also they help make sure that the constant is not outside the ones defined in the Enum.
Declaring Enums:
Here's how you declare Enums in Java.
public enum Color { RED, GREEN, BLUE, YELLOW, WHITE, BLACK }