static block vs inititalize block
Anónimo
Static Initialization Block Instance Initialization Block To define a static initialization block we use the keyword static No keyword is required to define an instance initialization block. A static initialization block loads as soon as a class loads and it is not associated with a call to the constructor of a class for object creation. An instance initialization block is only executed when there is a call to the constructor for creating an object. Static block can only access static variables and static methods of its class An instance initialization block can not only access static variables and static methods but also instance variables and instance methods of the class. There is no automatic call to superclass constructor from the static initialization block. An instance initialization block always makes an automatic call to superclass constructor by calling super() before executing any other statement in it. Static block is called just once during the entire execution of the program when the class loads. Instance initialization block can run many times, whenever there is a call to the constructor of the class