Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Java - Static Initializer
class StaticTest {
static int i;
static {
System.out.println("Static Initialization block is called");
i = 10;
}
StaticTest() {
System.out.println("Static Test Constructor is called");
}
}
class Main {
public static void main (String args[]){
System.out.println(StaticTest.i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment