I raised an issue at work, and simplified the code to reproduce it
public class Test {
public void callTest(){ return; }
public Test() { callTest(); }
}
public class Test1 extends Test{
private Integer myInt;
private Integer myNullInt = null;
public Test1() {
super();
}
@Override
public void callTest() {
myInt = 25;
myNullInt = 30;
}
@Override
public String toString() {
return "Test1{myInt=" + myInt + ", myNullInt=" + myNullInt +'}';
}
public static void main(String[] args) {
Test1 t1 = new Test1();
System.out.println(t1);
}
}
With this a a result : Test1{myInt=25, myNullInt=null}
On my understanding, instance variable initializers should be executed after the call to super(). So why is 'myInt' getting a value. And even how can it be possible ?