Okay, so, I have a kind of specific problem. I have a class structure similar to this (simplified for simplicity purposes).
class A {
A() {
// long initialization
}
A(int someValue) {
this();
// do something with someValue
}
}
class B extends A {
B() {
super();
// some long initialization
}
B(int someValue) {
// What should i do here ?
}
}
But now, i want to be able to construct class B
using the second constructor. But the second constructor should call the super(someValue)
constructor to make use of the someValue
parameter, but at the same time it needs to call this()
to to not have to duplicate the initialization of this class. The problem is that i can't call this
and super
constructors at the same time.
Also I can't extract the initialization in first constructor to some method, because I have some final
fields that needs to be initialized inside the constructor to stay final
.