Chapter 7. Enumerated Types

Table of Contents

Enumerated Types in Java 5
Enumerated Types in AspectJ 5

Enumerated Types in Java 5

Java 5 (and hence AspectJ 5) provides explicit support for enumerated types. In the simplest case, you can declare an enumerated type as follows:

      public enum ProgrammingLanguages {

Enumerated types are just classes, and they can contain method and field declarations, and may implement interfaces. Enums may only have private constructors, and may not be extended.

Enumerated types in Java 5 all implicitly extend the type java.lang.Enum. It is illegal to explicitly declare a subtype of this class.