Java – Static Initialization Block

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.dw.lib.test;
 
public class StaticInitializationBlock {
 
	static  
    {  
        System.out.println("STATIC BLOCK");  
    } 
 
	public StaticInitializationBlock() {
		System.out.println("constructor");
	}
 
	public static void main(String[] args) {
 
		StaticInitializationBlock block = new StaticInitializationBlock();
 
		System.out.println("MAIN METHOD");
 
	}
 
}

output:
STATIC BLOCK
constructor
MAIN METHOD