Section 8.9 enum Types
• All enum
types (p. 335) are reference types. An enum
type is declared with an enum
declaration, which is a comma-separated list of enum
constants. The declaration may optionally include other components of traditional classes, such as constructors, fields and methods.
• enum
constants are implicitly final
, because they declare constants that should not be modified.
• enum
constants are implicitly static
.
• Any attempt to create an object of an enum
type with operator new
results in a compilation error.
• enum
constants can be used anywhere constants can be used, such as in the case
labels of switch
statements and to control enhanced for
statements.
• Each enum
constant in an enum
declaration is optionally followed by ...
Get Java™ How To Program (Early Objects), Tenth 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.