Java Reference
In-Depth Information
Returns the ordinal value of an enum constant. Enum con-
stants are given ordinal values based on the order they are
declared: the first declared constant has an ordinal value of
zero, the second has an ordinal value of one, etc.
public final Class< E > geTDeclaringClass()
Returns the Class object representing the enum type of this
enum constant. This will be different from the value returned
by Object.getClass for any enum constant that is set to an an-
onymous inner class object.
The Enum class also provides a static utility method, valueOf , that takes
a class object for an enum type, and a name, and returns the named
enum constant from the given enum. If the enum doesn't have a enum
constant by that name then IllegalArgumentException is thrown.
In addition to the Enum class, there are two highly efficient enum-specific
collection classes: EnumSet defines a set for use with enum values, and
EnumMap is a specialized map for which keys are enum values. These spe-
cialized collection classes are described further in Chapter 21 .
 
Search WWH ::




Custom Search