Created
August 28, 2015 07:03
-
-
Save tycoi2005/b3db25fbaefa4663fd02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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