close

from http://www.dotblogs.com.tw/pin0513/archive/2010/03/08/13931.aspx

 1: public class Singleton{

   2:     //透用一個靜態變數記錄實體
   3:     private static Singleton uniqueInstance;
   4:     //建構式的啦
   5:     private Singleton(){}
   6:     public static Singleton getInstance(){
   7:         if (uniqueInstance == null)
   8:             uniqueInstance = new Singleton();
   9:         return uniqueInstance;
  10:     }
  11: }

 

 

 

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 AndrewHsiao 的頭像
    AndrewHsiao

    Andrew的部落格

    AndrewHsiao 發表在 痞客邦 留言(0) 人氣()