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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access