Any way to _not_ call superclass constructor in Java?

后端 未结 13 1365
误落风尘
误落风尘 2020-12-15 04:16

If I have a class:

class A {
   public A() { }
}

and another

class B extends A {
   public B() { }
}

is t

13条回答
  •  执笔经年
    2020-12-15 04:39

    I think the only way to do it is messing up with the byte-code.
    I'm not sure if the Classloader or the JVM checks if super() is being called, but, as Bozho wrote, you probably would end with inconsistent objects when doing so.

提交回复
热议问题