I Have doubts about how it work static blocks in Java. As I understood, code inside static block is executed everytime that the class is loaded by JVM. What I don't understand is WHEN exactly a class is loaded.
For Example, let's suppose I have static Block inside the class MyObject
, and then from another class I have this code:
MyObject o1= new MyObject();
MyObject o2= new MyObject();
How many times the static block is executed in this case?