Enumerated types
Enumerated types are defined using the keyword
enum. Enumerated types are simply another way
to name constants. For example
enum Day {SUNDAY, MONDAY, TUESDAy, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY};
Be default, the identifiers are given int values, starting at zero.
So, SUNDAY has the value zero, MONDAY has the value one, and so on.
You can give them different values if you'd like:
enum Shape {RECTANGLE=20, CIRCLE=30, TRIANGLE=40};
Assignment is the only operatorion defined for enumerated types.
You can use ints to do some manipulation, but only by casting
back and forth. For example:
Day payday = FRIDAY;
int i = payday; // legal cast, i is 5
Day weekend = Day(++i); // cast back to Day type, weekend is SATURDAY
Note that C/C++ enumerated types have nothing to do with Java's
Enumeration class.