1

I have the following class.

public abstract class MyRoot extends Object {

    public MyRoot () {
        super();
        this.initObj();
    }

    protected abstract void initObj();
}

All other classes in project extend this class MyRoot. The subclasses put the initialization stuff in initObj().

public class MyCard extends MyRoot
{
    public MyCard()
    {
       super();
    }

    private ArrayList<Person> persons;

    @Override
    protected void initObj()
    {
       this.persons = new ArrayList<Person>();
    }
}

In class MyCard I do all initialization in initObj() and everything seems to work. What's wrong with this approach of initializing everything in initObj()? Netbeans points to initObj() in MyRoot's constructor and warns that I have overridable method call in constructor

0 Answers0