Enums introduced type safety to the use of constants, which were defined previously by using static, and final variables of a type such as int.
A quick background
An example
Imagine limiting the sizes of a shirt to some predefined sizes (such as Small, Medium, and Large). The following code shows how you can do that with an enum (Size):
enum Size {SMALL, MEDIUM, LARGE}
Java's coding guidelines recommend using uppercase to define enum constants (such as SMALL). Multiple words in a constant can be separated by using an underscore.
The following code shows how you can use the Size enum in a class, Shirt, to restrict its sizes to constants defined in the Size enum:
class Shirt { Size size; // instance...