java.lang
public abstract class Enum<T extends Enum<T>> extends Object implements Comparable<T>, Serializable
Since: 1.5
Constructor Summary | |
---|---|
protected | Enum(String name, int ordinal)
This constructor is used by the compiler to create enumeration constants.
|
Method Summary | |
---|---|
protected Object | clone()
Cloning of enumeration constants is prevented, to maintain their
singleton status.
|
int | compareTo(T e)
Returns an integer which represents the relative ordering of this
enumeration constant. |
boolean | equals(Object o)
Returns true if this enumeration is equivalent to the supplied object,
o . |
protected void | finalize()
Enumerations can not have finalization methods.
|
Class<T> | getDeclaringClass()
Returns the type of this enumeration constant. |
int | hashCode()
Returns the hash code of this constant. |
String | name()
Returns the name of this enumeration constant.
|
int | ordinal()
Returns the number of this enumeration constant, which represents
the order in which it was originally declared, starting from zero.
|
String | toString()
Returns a textual representation of this enumeration constant.
|
Parameters: name the name of the enumeration constant. ordinal the number of the enumeration constant, based on the declaration order of the constants and starting from zero.
Returns: the cloned object.
Throws: CloneNotSupportedException as enumeration constants can't be cloned.
Parameters: e the enumeration constant to compare.
Returns: a negative integer if e.ordinal < this.ordinal
,
zero if e.ordinal == this.ordinal
and a positive
integer if e.ordinal > this.ordinal
.
Throws: ClassCastException if e
is not an enumeration
constant of the same class.
o
. Only one instance of an enumeration constant exists,
so the comparison is simply done using ==
.
Parameters: o the object to compare to this.
Returns: true if this == o
.
Since: 1.6
Returns: the type of this enumeration constant.
Returns: the hash code of this enumeration constant.
Returns: the name of the constant.
Returns: the number of this constant.
Returns: a textual representation of this constant.