Enum class Methods in Java

java.lang.Enum

This is the common base class of all Java language enumeration types.


Some of the Methods of  Enum class.


compareTo(): This method compares this enum with the specified object for order.


describeConstable(): Returns an enum descriptor EnumDesc for this instance if one can be constructed, or an empty Optional if one cannot be.


equals(): This method returns true if the specified object is equal to this enum constant.


getClass(): This method returns the runtime class of this Object.


hashCode(): This method returns a hash code for this enum constant.


name(): This method returns the name of this enum constant, exactly as declared in its enum declaration.


ordinal(): This method returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).


toString(): This method returns the name of this enum constant, as contained in the declaration.


No comments:

Post a Comment