I'm having a design problem which I don't know how to overcome in java. I want to override a method that is called from the parent constructor. Here is a very simple example of the problem:
public class Parent {
public Parent(){
a();
}
public void a() {
// CODE
return;
}
}
public class Child extends Parent {
public Child() {
super();
}
public void a() {
super.a();
// MORE CODE
return;
}
}
I know that the child class wont be initialized until the parent is constructed therefore the childs a() method wont be called. What is the correct design to overcome this problem?