Possible duplicate:
Static Initialization Blocks
Consider the following code:
public class Test { { System.out.println("Empty block"); } static { System.out.println("Static block"); } public static void main(String[] args) { Test t = new Test(); } }
We understand that a static block will be executed first, followed by an empty block. But the problem is that I could never understand the real usefulness of an empty block. Can anyone show a real example in which -
- Both static and empty blocks are used.
- Both static and empty blocks have different utilities.
java initialization-block static-block
Anshu Sep 23 2018-12-12T00: 00Z
source share