Although that code would compile neither in C nor C++, your basic problem is here:
System.out.println(h.m1() + "......" + h.m2() + "......." + h.m3());
In C and C++ there are no constraints on how the compiler orders those calls. It could call m3 then m2 then m1, or m2 then m3 then m1, etc, etc… It is implementation defined behaviour and you cannot rely on it.
1
solved Java and C: different outputs of same code [closed]