why Cannot invoke super constructor from enum constructor ?

Posted by hilal on Stack Overflow See other posts from Stack Overflow or by hilal
Published on 2010-12-24T08:09:39Z Indexed on 2010/12/24 9:54 UTC
Read the original article Hit count: 253

public enum A {
     A(1);

     private A(int i){
     }

     private A(){
         super(); // compile - error
             // Cannot invoke super constructor from enum constructor A()
     }

}

and here is the hierarchy of enum A extends from abstract java.lang.Enum extends java.lang.Object

Class c = Class.forName("/*path*/.A");
System.out.println(c.getSuperclass().getName());
System.out.println(Modifier.toString(c.getSuperclass().getModifiers()).contains("abstract"));
System.out.println(c.getSuperclass().getSuperclass().getName());

© Stack Overflow or respective owner

Related posts about java

Related posts about reflection