Professional Documents
Culture Documents
Example :
Declare cp as a variable of enumeration type
Color :
Color cp;
The only values that It can be assigned to
Color variable type ‘cp’ are those defined by
the enumerations.
Example :
cp = Color. Red;
Notice that the symbol Red is preceded
by Color.
Example :
switch (cp) {
case Red:
case Blue:
}
All enumerations automatically contain two
predefined methods :
values() and valueof().
Their general forms are shown here: