Running a method after the constructor of any derived class
- by Alexey Romanov
Let's say I have a Java class
abstract class Base {
abstract void init();
...
}
and I know every derived class will have to call init() after it's constructed. I could, of course, simply call it in the derived classes' constructors:
class Derived1 extends Base {
Derived1() {
...
init();
}
}
class Derived2…