Java Enum getDeclaringClass() MethodThe getDeclaringClass() method of Enum class returns the object of Class representing the enum type of this enum constant. Suppose there are two enum constants e1 and e2, they are of the same enum type if SyntaxParametersNA Return ValueThe getDeclaringClass() method returns the Class object representing the enum type of this enum's constant. Example 1Test it NowOutput: classcom.javaTpoint.BodyPart Example 2Test it NowOutput: 1. Deer is in class com.javaTpoint.Enum_getDeclaringClassMethodExample2$Herbivores enum class 2. Wolf is in class com.javaTpoint.Enum_getDeclaringClassMethodExample2$Carnivores enum class 3. Bear is in class com.javaTpoint.Enum_getDeclaringClassMethodExample2$Omnivores enum class
Next TopicJava Enum
|