Enumerations, or enums, were introduced in Java 5, with the keyword enum. Code written before this may use enum as an identifier. To compile such code, you must compile it with a command such as javac -source 1.4 .... However, this means that you cannot use any new features that are provided in Java 5 and later.

To make it easier to compile the code and add code that uses new Java features, rename any identifiers that are named enum in legacy code.

In the following example, enum is used as the name of a variable. This means that the code does not compile unless the compiler's source language is set to 1.4 or earlier. To avoid this constraint, the variable should be renamed.

  • Java Language Specification: 8.9 Enum Types.