静的内部クラスの単一モード



  
  
  
  
  1. public class Singleton { 
  2.     /** 
  3.      *  , , , 
  4.      *  ,  
  5.      */ 
  6.     private static class SingletonHolder{ 
  7.         /** 
  8.          *  , JVM  
  9.          */ 
  10.         private static Singleton instance = new Singleton(); 
  11.     } 
  12.     /** 
  13.      *   
  14.      */ 
  15.     private Singleton(){ 
  16.     } 
  17.      
  18.     public static  Singleton getInstance(){ 
  19.         return SingletonHolder.instance; 
  20.     } 

簡単明瞭かどうか見てみましょう.