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 1Output: classcom.javaTpoint.BodyPart Example 2Output: 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-hashcode-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India