why is the static block useful java
Static blocks are mainly used for initialization of static variables of class which you can't do with the help of constructors. Here are some rules which governs functioning of static blocks:-. 1) They are called when a class is loaded into the JVM. 2) They are executed in the order which they appear in the class. 3) They are executed only once. 4) They are used as class level members only - which means you CANNOT put them inside any methods.