In Fig. D.5, we introduced the basic
enum type, which defines a set of constants represented as unique identifiers. In that program the
enum constants represented the game’s status. In this section we discuss the relationship between
enum types and classes. Like classes, all
enum types 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. Each
enum declaration declares an
enum class with the following restrictions:
enum constants are implicitly
final, because they declare constants that shouldn’t be modified.
enum constants are implicitly ...