I have simple three classes:
class A {
public A(int a){ }
}
class B extends A {
public B(int b){ super(b); }
}
class C extends B {
public C(int c){ super(c); }
}
So, the order of execution during class instancing is C->B->A->B->C and all objects are instantiated correctly. Then, the question:
CAN I in some way write a constructor for C class like this:
public C(int c){
super.super(c);
}
The idea is to call the constructor from A class, not from immediate parent B. Is this possible?
No you can't do that.
All classes in a heirarchy need to be constructed. You cannot bypass the construction of B
.
What you could do is write a protected
constructor in B
that's essentially a no-op, and call that from the constructor in C
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With