Probably unexpected behavior:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
public class Main { public static void main(String[] args) { mew SomeSub(); } public abstract static class SomeSuper { public SomeSuper(){ doInit(); } public abstract void doInit(); } public static class SomeSub extends SomeSuper { public int someIntMember = 3; public void doInit(){ System.out.println(someIntMember); // prints 0, not 3 } } } |
There’s not a direct way to work around this – often initialization or setup methods are used, sometimes with a Factory instance generator.