Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 5th, 2012  |  syntax: None  |  size: 0.33 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. singleton-early initialization ,static field initialization and class loading
  2. class MyClass {
  3.     private static MyClass myobj = new MyClass();
  4.  
  5.     private MyClass() {
  6.     }
  7.  
  8.     public  static MyClass getMyobj() {
  9.         return myobj;
  10.     }
  11. }
  12.        
  13. MyClass.getMyobj();
  14. MyClass.getMyobj();
  15.        
  16. public enum MyClass {
  17.    myobj;
  18. }