[Solved] In the below java program I didn’t understand flow of execution and about “this” keyword execution?


Your constructor prints one line, so :

new This();
System.out.println(new This());

Here you call the constructor twice, and System.out.println() also prints a line, so you get three lines.
Also, you are creating two distinct This objects.

In your second example, the constructor is only called once, so you get only two lines.
This example creates only one This object :

This t = new This();
System.out.println(t);

2

solved In the below java program I didn’t understand flow of execution and about “this” keyword execution?