E
- The enum type subclasspublic abstract class Enum<E extends Enum<E>> extends Object implements Comparable<E>
Modifier | Constructor and Description |
---|---|
protected |
Enum(String name,
int ordinal)
Sole constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Object |
clone()
Throws CloneNotSupportedException.
|
int |
compareTo(E o)
Compares this enum with the specified object for order.
|
boolean |
equals(Object other)
Returns true if the specified object is equal to this
enum constant.
|
protected void |
finalize()
enum classes cannot have finalize methods.
|
int |
hashCode()
Returns a hash code for this enum constant.
|
String |
name()
Returns the name of this enum constant, exactly as declared in its
enum declaration.
|
int |
ordinal()
Returns the ordinal of this enumeration constant (its position
in its enum declaration, where the initial constant is assigned
an ordinal of zero).
|
String |
toString()
Returns the name of this enum constant, as contained in the
declaration.
|
static <T extends Enum<T>> |
valueOf(Class<T> enumType,
String name)
Returns the enum constant of the specified enum type with the
specified name.
|
protected Enum(String name, int ordinal)
name
- - The name of this enum constant, which is the identifier
used to declare it.ordinal
- - The ordinal of this enumeration constant (its position
in the enum declaration, where the initial constant is assigned
an ordinal of zero).public final String name()
public final int ordinal()
public String toString()
public final boolean equals(Object other)
equals
in class Object
other
- the object to be compared for equality with this object.Boolean.hashCode()
,
Hashtable
public final int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
Hashtable
protected final Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
- by designCloneable
public final int compareTo(E o)
compareTo
in interface Comparable<E extends Enum<E>>
o
- the object to be compared.public static <T extends Enum<T>> T valueOf(Class<T> enumType, String name)
T
- The enum type whose constant is to be returnedenumType
- the Class
object of the enum type from which
to return a constantname
- the name of the constant to returnIllegalArgumentException
- if the specified enum type has
no constant with the specified name, or the specified
class object does not represent an enum typeNullPointerException
- if enumType
or name
is null