enum Type Status

Local variable gameStatus (line 24) is declared to be of a new type called Status (declared at line 11). Type Status is a private member of class Craps, because Status will be used only in that class. Status is a type called an enum type, which, in its simplest form, declares a set of constants represented by identifiers. An enum type is a special kind of class that’s introduced by the keyword enum and a type name (in this case, Status). As with classes, braces delimit an enum declaration’s body. Inside the braces is a comma-separated list of enum constants, each representing a unique value. The identifiers in an enum must be unique. You’ll learn more about enum types in Chapter 8.

Good Programming Practice 6.1

Use only uppercase ...

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.