8.9. Enums
An enum declaration specifies a new enum type.
EnumDeclaration: ClassModifiersopt enum
Identifier Interfacesopt EnumBodyEnumBody: {
EnumConstantsopt ,
opt EnumBodyDeclarationsopt }
Enum types (§8.9) must not be declared abstract
; doing so will result in a compile-time error.
An enum type is implicitly final
unless it contains at least one enum constant that has a class body.
It is a compile-time error to explicitly declare an enum type to be final
.
Nested enum types are implicitly static
. It is permissible to explicitly declare a nested enum type to be static
.
This implies that it is impossible to define a local (§14.3) enum, or to define an enum in an inner class (§8.1.3).
The direct superclass of an enum type named E is
Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition 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.