First page Back Continue Last page Overview Graphics

Enums - recap


Notes:

Only one copy of each value (instance) of an
Enum class is allowed.

Natural enumerated types
─ Days of week, phases of moon, seasons, compass
points, colors in spectrum
• Other sets where you know all possible values
─ Choices on Menu, Rounding modes, command line
flags, opcodes in instruction set
─ Can add more in new version of API
• As a replacement for flags (EnumSet)

�� The operator == works fine.
�� No new instances allowed.
�� No public constructors allowed.
�� No subclasses allowed (messy semantics).
�� Each instance must be created.
�� Static initializers cannot refer to the instances.