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 enumeration, which, in its simplest form, declares a set of constants represented by identifiers. An enumeration 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 enumeration constants, each representing a unique value. The identifiers in an enum
must be unique. You’ll learn more about enumerations in Appendix F.
Get Android™ How to Program, Second 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.