Skip to content

Instantly share code, notes, and snippets.

@tycoi2005
Created August 28, 2015 07:03
Show Gist options
  • Save tycoi2005/b3db25fbaefa4663fd02 to your computer and use it in GitHub Desktop.
Save tycoi2005/b3db25fbaefa4663fd02 to your computer and use it in GitHub Desktop.
/* package whatever; // don't place package name! */
// http://www.programcreek.com/2013/01/when-and-how-a-java-class-is-loaded-and-initialized/
// http://www.programcreek.com/2011/10/java-class-instance-initializers/
// https://ideone.com/6mkS8l
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
C c= new C();
B.doB();
}
}
class A {
static {
System.out.println("A static initialize");
}
}
class B {
static {
System.out.println("B static initialize");
}
public static void doB(){
System.out.println("doB");
}
}
class C {
static {
System.out.println("C static initialize");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment