Why do we use static initializer blocks?
Static initializer blocks tend to be used in classes that have important properties and behaviour that are accessed in a static context and may require some runtime configuration. A static initializer block is similar in nature to a class constructor, except it is executed when the class is first loaded by the Java runtime system, before any instance is created. Static initialization blocks may set the initial value of static variables using relatively complex logic, execute Java statements and call other methods. Since this code runs before any instance of the host class exists, it cannot work with instance variables or methods of its own. Static initializer blocks enable programmers to run relatively complex code during class loading to prepare a class for use in a purely static context, or when it would be “too late” to run the code in a constructor call.