This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
This is a non-static initialisation block. This line isn't executed because no object is being instantiated. These blocks are only executed when an object is instantiated and are executed in the order that they appear.
In the case of the static initialisation blocks these are executed when the class is loaded.
Joined: Feb 28, 2007
If i create an object of class tt (new tt() , in that case the initializer block gets executed. Like the code you mentioned will give o/p as:
I just wanted to know if the compiler will never complain of such initializer blocks where we aren't having a statement calling constructor or not?