Java 5 supports enumerated types. These replace the old typesafe enum pattern, and are much more compact and easy to maintain. They can be used to list such collections of values as the days of the week or the suits of a deck of cards, or any fixed set of constants, such as the elements in a menu.
These anonymous classes will be displayed on the Inner Classifiers tab of the Enum class property sheet:
The Operation enum class, with an anonymous class for each of its EnumConstants to allow for the varied arithmetic operations, could be represented in a class diagram as follows:
The equivalent code would be like the following: