Since you need to create a concrete subclass anyways you need to implement entityInit()
as well. That method will then be called.
You can't create instances of abstract classes and concrete class (which you can create instances of) must not have abstract methods. So everything is fine.
One note: be aware that if you access fields defined in the subclass, accessing them in entityInit()
might result in a NullPointerException since they might not be initialized.
Example (based on your class):
class Person extens Entity {
private String name = "Player";
protected void entityInit() {
int nameLen = name.length(); //NPE here!!!
}
}
Although that example doesn't make much logical sense, it should illustrate the point.
First the Entity
constructor will be called, which in turn calls entityInit()
. However, since the initializer block of Person
has not run yet, name
is still null.