1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| public enum MyEnum {
UN{public void test(){System.out.println("1");}},
DEUX{public void test(){System.out.println("deux");}};
public abstract void test();
}
public enum MyLastEnum {
UN{public void test(){System.out.println("1");}},
DEUX{public void test(){System.out.println("deux");}};
public void test(){System.out.println("default");};
}
public enum MyOtherEnum {
UN,
DEUX;
}
public static void main(String[] args) {
for (MyEnum e : MyEnum.values()){
System.out.printf("Class is %s and parent is %s and super parent is %s\n",
e.getClass().getName(),
e.getClass().getSuperclass().getName(),
e.getClass().getSuperclass().getSuperclass().getName());
}
System.out.println("MyEnum modifiers: "+Modifier.toString(MyEnum.class.getModifiers()));
for (MyOtherEnum e : MyOtherEnum.values()){
System.out.printf("Class is %s and parent is %s and super parent is %s\n",
e.getClass().getName(),
e.getClass().getSuperclass().getName(),
e.getClass().getSuperclass().getSuperclass().getName());
}
System.out.println("MyOtherEnum modifiers: "+Modifier.toString(MyOtherEnum.class.getModifiers()));
for (MyLastEnum e : MyLastEnum.values()){
System.out.printf("Class is %s and parent is %s and super parent is %s\n",
e.getClass().getName(),
e.getClass().getSuperclass().getName(),
e.getClass().getSuperclass().getSuperclass().getName());
}
System.out.println("MyLastEnum modifiers: "+Modifier.toString(MyLastEnum.class.getModifiers()));
} |
Partager