public
final Class<E> getDeclaringClass()
Returns
the Class object corresponding to this enum constant's enum type. Two
enum constants e1 and e2 are of the same enum type if and only if
e1.getDeclaringClass() == e2.getDeclaringClass().
enum Day{ MON, TUE, WED, THU, FRI, SAT, SUN; public static void main(String args[]){ for(Day d1 : Day.values()){ System.out.print("Class for " + d1 + " is "); System.out.println(d1.getDeclaringClass()); } } }
Output
Class for MON is class Day Class for TUE is class Day Class for WED is class Day Class for THU is class Day Class for FRI is class Day Class for SAT is class Day Class for SUN is class Day
No comments:
Post a Comment