posted 15 years ago
In new A().new B(); case it will print A0B0 is ok.
Then as in getCounter() and getInnerCounter() post increment operators are used.Then Counter and InnerCounter is set to 1.
But then A a1 = new A();constructor is used only once so,Counter only incremented once
and So A1 is printed twice
but as a1.new B(); // 3
a1.new B(); // 4
used, So new B() is used twice. And InnerCounter incremented twice.