+ 3
What are the advantages of Static blocks in Java?
In Java we have different static blocks and initializers. Where should we use for what?
2 Respostas
+ 6
You must have heard that in Java the main() method runs first. But if your code is having the static block then it will run before the main() method
Static block is mainly used to initialize the static members
+ 4
They make some initializations without taking cure if an instance of that class is created or not and usually contain dependencies (like load to native libraries or to global class variables) that have to inited only once time