0
How to use static block in Java?
4 Respostas
+ 3
static initialization is being done when class is loaded by class loader and constructor when new instance is created
+ 3
The static block is executed first as it's necessary while the class is loaded. After the Class is loaded and it comes to creating objects of that type, the main method is called from the constructor.
+ 2
Only when the class is loaded, not when it's instantiated. Static is not related to class instances. (static means the member is bound to the class).
The static block would run before the main method
0
In static block create the static method so first static method call or main method??