Skip to content

Instantly share code, notes, and snippets.

@LazaroIbanez
Created September 3, 2017 17:21
Show Gist options
  • Save LazaroIbanez/86fe477bc0e9c0073e54ca9a43d38e8f to your computer and use it in GitHub Desktop.
Save LazaroIbanez/86fe477bc0e9c0073e54ca9a43d38e8f to your computer and use it in GitHub Desktop.
static initialization
public class A {
static { System.out.println(“A Loaded”); }
public static void main(String[] args) {
System.out.println(“A should have been loaded”);
A1 a1 = null;
System.out.println(“A1 should not have been loaded”);
System.out.println(a1.i);
}
}
class A1 {
static int i = 10;
static { System.out.println(“A1 Loaded”); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment