This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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?