[Java] 单例模式Singleton →→→→→进入此内容的聊天室

来自 , 2019-02-12, 写在 Java, 查看 134 次.
URL http://www.code666.cn/view/cfbce4c1
  1. public class Singleton {
  2.  
  3.     //Fields
  4.     private static Singleton instance;
  5.     //Standard default Constructor
  6.     protected Singleton(){};
  7.     //Static method for creating the single instance of the Constructor
  8.     public static Singleton Instance(){
  9.         //initialize if not already done
  10.         if(instance == null)
  11.         instance = new Singleton();
  12.         //return the initialized instance of the Singleton Class
  13.         return instance;
  14.     }
  15. }

回复 "单例模式Singleton"

这儿你可以回复上面这条便签

captcha