Sunitha, Here is what the
java Specification say about initilization of instance and static blocks.
8.6 Instance Initializers
An instance initializer declared in a class is executed when an instance of the class
is created (�15.9), as specified in �8.8.7.1.
InstanceInitializer:
8.7 Static Initializers
Any static initializers declared in a class are executed when the class is initialized
and, together with any field initializers (�8.3.2) for class variables, may be used to
initialize the class variables of the class (�12.4).
This came from the pdf version if you want to read it.
Also, all the varibles you declared in the static and instance initalizers have scope only within the block of the initalizer. In other words all the varibles you create in your examples can't be used outside of the block where you created them. example:
The following code will print 0 not 23. This because the foo varible declared in the initilizer block is a differnt varible then the one declared in the test1 class. Hoped this helped.