Java Reference
In-Depth Information
Chapter 6. Enumeration Types
Four be the things I am wiser to know: Idleness, sorrow, a friend,
and a foe. Four be the things I'd been better without: Love, curi-
osity, freckles, and doubt. Three be the things I shall never attain:
Envy, content, and sufficient champagne. Three be the things I shall
have till I die: Laughter and hope and a sock in the eye.
Dorothy Parker, "Inventory"
An enumeration type sometimes known as an enumerated type, or more
simply as an enum is a type for which all values for the type are known
when the type is defined. For example, an enum representing the suits in
a deck of cards would have the possible values hearts, diamonds, clubs,
and spades; and an enum for the days of the week would have the values
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday.
In some programming languages, enums are nothing more than a set of
named integer values, but in the Java programming language an enum
is a special kind of class, with an instance that represents each value of
the enum.
 
Search WWH ::




Custom Search