>>it looks like the static block is executed only once
Yes the static initialization block is executed only once no matter how many objects of the class you have.
Suppose you have a class type
Test and you want to instantiate an object with the name 'myTest' using constructor myTest1=new Test(); In that case, overall process is as follows--
1) First the class file is loaded into JVM and right that time static block runs. Remember static block will run only once.
2) First a constructor of the superclass of the Test class is called and variables are initialized according to the code in the superclass constructor.In the superclass constructor, first thing done is invoking its superclass constructor and this process goes on and on till class Object's constructor is invoked.
3) Then code returns to the constructor of Test class.Before any other code in the test class constructor is invoked,the non-static initialization bloak in the code of Static class is invoked.
4) Suppose you want to create another object of class Test and you write Test myClass2=new Test(); In this case, steps 2 and 3 are run but not step #1.
So point to remember is static initialization block will be run only once the moment class file is loaded into JVM.Non-static initialization blocks will be run once for each object of the class created using new.There could be more than one static/non-static initialization blocks in the code.They are executed in the order in which they appear.
Hope this helps.
----Vishram