Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes

Java Enum Class

Java.lang package provides an Enum class which is the common base class of all Java language enumeration types.

Class declaration

The declaration of java.lang.Enum class is:

public abstract class Enum<E extends Enum<E>>
  extends Object
    implements Comparable<E>, Serializable

Class Constructor

S.NConstructors & Description
1. protected Enum(String name, int ordinal)
Sole constructor.

java.lang.Enum Methods

The java.lang.Enum class has a number of methods which are listed below:

Member Methods

S.NMethods & Description
1. protected Object clone()
Throws CloneNotSupportedException.
2. int compareTo(E o)
Compares this enum with the specified object for order.
3. boolean equals(Object other)
Returns true if the specified object is equal to this enum constant.
4. protected void finalize()
enum classes cannot have finalize methods.
5. Class<E> getDeclaringClass()
Returns the Class object corresponding to this enum constant's enum type.
6. int hashCode()
Returns a hash code for this enum constant.
7. String name()
Returns the name of this enum constant, exactly as declared in its enum declaration.
8. 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).
9. String toString()
Returns the name of this enum constant, as contained in the declaration.
10. static <T extends Enum<T>> T valueOf(Class<T> enumType, String name)
Returns the enum constant of the specified enum type with the specified name.

Methods inherited

This class inherits the methods of following class:

  • java.lang.Object