E
-枚举类型的子类
public abstract class Enum<E extends Enum<E>> extends Object implements Comparable<E>, Serializable
Class.getEnumConstants()
,
EnumSet
,
EnumMap
,
Serialized Form
Modifier and Type | Method and Description |
---|---|
protected Object |
clone()
把clonenotsupportedexception。
|
int |
compareTo(E o)
这个枚举与指定对象按顺序比较。
|
boolean |
equals(Object other)
如果指定的对象是否等于这个枚举常数返回true。
|
protected void |
finalize()
枚举类不能有Finalize方法。
|
类<E> |
getDeclaringClass()
返回此枚举常量的枚举类型对应的类对象。
|
int |
hashCode()
返回此枚举常量的哈希代码。
|
String |
name()
返回此枚举常量的名称,如宣布在其枚举声明。
|
int |
ordinal()
返回此枚举常量的顺序(位置在枚举声明,在初始常数是零分序号)。
|
String |
toString()
返回此枚举常量的名称,包含在声明。
|
static <T extends Enum<T>> |
valueOf(类<T> enumType, String name)
返回指定枚举类型具有指定名称的枚举常数。
|
protected Enum(String name, int ordinal)
name
-该枚举常量的名称,它是用来声明它的标识符。
ordinal
-此枚举常数的顺序(位置在枚举声明,在初始常数是零分序号)。
public final String name()
toString()
方法,如toString方法会返回一个更友好的名称。方法设计主要是用专业的情况下,正确性取决于确切的名称,它不会改变释放释放。
public final int ordinal()
public String toString()
public final boolean equals(Object other)
equals
方法重写,继承类
Object
other
-比较与该对象平等的对象。
Object.hashCode()
,
HashMap
public final int hashCode()
hashCode
方法重写,继承类
Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
protected final Object clone() throws CloneNotSupportedException
clone
方法重写,继承类
Object
CloneNotSupportedException
-如果对象的类不支持
Cloneable
接口。子类重写
clone
方法也抛出该异常表示实例无法克隆。
Cloneable
public final int compareTo(E o)
compareTo
接口
Comparable<E extends Enum<E>>
o
要比较的对象。
public final 类<E> getDeclaringClass()
Object.getClass()
方法返回)
public static <T extends Enum<T>> T valueOf(类<T> enumType, String name)
值得注意的是,对于一个特定的类型T
,隐式声明的方法,public static T valueOf(String)
枚举可以代替这种方法Map从名称到对应的枚举常量。枚举类型的所有常数可以通过调用该类型的隐式public static T[] values()
方法得到的。
T
的常数是要返回的枚举类型
enumType
-从枚举类型返回一个常数的
类
对象
name
-常量的名称返回
IllegalArgumentException
-如果指定枚举类型,也没有固定的具有指定名称,或指定的类的对象并不代表一个枚举类型
NullPointerException
-如果
enumType
或
name
是空的
protected final void finalize()
finalize
方法重写,继承类
Object
WeakReference
,
PhantomReference
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.