Using Enums

FRIDGE

The code in this book was compiled and executed using the JDK 5.0 alpha and beta releases, and it is possible that there are changes between these and the final release. If you want to switch between different compilers, you can use the - source 1.5 switch to the javac command.

Enums are new with Java 5.0. Enum is short for enumeration, and enums are useful when you want to define values that are meaningful to the user (in this case, other programmers) that can be switched against. The Enum is defined in the java.lang package.

When to Use an Enum

Programmers may be familiar with the enum, which programmers may be familiar with ...

Get Java Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.