Skip to content

Instantly share code, notes, and snippets.

@anjanashankar9
Created July 9, 2019 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anjanashankar9/717e2d0331d5bdff8f0bb6ed25997771 to your computer and use it in GitHub Desktop.
Save anjanashankar9/717e2d0331d5bdff8f0bb6ed25997771 to your computer and use it in GitHub Desktop.
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