This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
This is correct, and happens because static intializers execute when the VM starts. Therefore, your static references t1 and t3 get created first, and then t2 (non-static) gets created once your application begins executing. Since static instance t1 is declared before t3, it gets created in that order.
Joined: Feb 13, 2009
But Sir, static blocks have a syntax of:
But in my program , they are not static blocks, They are just static reference variables. As far as i know only static blocks gets executed before the main() method is started. So i m still confused about the output............!!!
Joined: Jun 15, 2009
Although t1 and t3 are declared as static fields, they are still statically initialized, and my explanation still applies.