enum 사용 예제
java.lang
Class Enum<E extends Enum<E>>
- java.lang.Object
-
- java.lang.Enum<E>
-
- Type Parameters:
E
- The enum type subclass
- All Implemented Interfaces:
- Serializable, Comparable<E>
public abstract class Enum<E extends Enum<E>> extends Object implements Comparable<E>, Serializable
This is the common base class of all Java language enumeration types. More information about enums, including descriptions of the implicitly declared methods synthesized by the compiler, can be found in section 8.9 of The Java™ Language Specification.Note that when using an enumeration type as the type of a set or as the type of the keys in a map, specialized and efficient set and map implementations are available.
- Since:
- 1.5
- See Also:
Class.getEnumConstants()
,EnumSet
,EnumMap
, Serialized Form
-
Constructor Summary
Constructors Modifier Constructor and Description protected
Enum(String name, int ordinal)
Sole constructor. -
Method Summary
Methods 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.Class<E>
getDeclaringClass()
Returns the Class object corresponding to this enum constant's enum type.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>>
TvalueOf(Class<T> enumType, String name)
Returns the enum constant of the specified enum type with the specified name.
'Dev. 자바 > API 및 이론' 카테고리의 다른 글
[JAVA API] java.io.FileInputStream (0) | 2012.08.08 |
---|---|
[JAVA API] java.io.File (1) | 2012.08.08 |
[JAVA API] java.util.HashMap<K,V> (0) | 2012.08.07 |
[JAVA API] java.lang.Exception (0) | 2012.08.07 |
[JAVA API] java.util.Stack<E> (0) | 2012.08.07 |