An
enumeration, or
enum
, is a type that consists of a fixed list of named constants. To create one, the
enum keyword is used followed by a name and a code block containing a comma-separated list of constant elements. The access level for an enum is the same as for a class. Package-private by default, but it can also be set to public if it’s declared in a file of the same name. As with classes, an enum can also be contained within a class, where it can then be set to any access level.
enum Speed
{
STOP, SLOW, NORMAL, FAST
}
An object of the enum type just shown can hold any one of the ...