JAVA基础--单例模式

public class Singleton02 { 
// 私有的静态的类变量 private static Singleton02 instance = null; // 私有的构造方法 private Singleton02() { } // 静态的公有的方法 public static Singleton02 getInstance() { if (instance == null) { instance = new Singleton02(); } return instance; }
}

  

原文地址:https://www.cnblogs.com/wujixing/p/5430114.html