Class getEnumConstants() method in Java with Examples
The getEnumConstants() method of java.lang.Class class is used to get the Enum constants of this class. The method returns the Enum constants of this class in the form of an array of objects comprising the enum class represented by this class.
public T getEnumConstants()
Parameter: This method does not accepts any parameter
Return Value: This method returns the specified Enum constants of this class in the form of an array of Enum objects.
Below programs demonstrate the getEnumConstants() method.
Class represented by myClass: class A Enum constants of myClass: 
Class represented by myClass: class A Enum constants of myClass: [RED, GREEN, BLUE]
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.