标签:style blog color ar java sp div on log
class Singleton { private static Singleton instance = null; private Singleton() { System.out.println("Init the Singleton instance!"); } public static Singleton getInstance() { if (null == instance) instance = new Singleton(); return instance; } } public class SingletonPattern { /** * @param args */ public static void main(String[] args) { Singleton instanceA = Singleton.getInstance(); Singleton instanceB = Singleton.getInstance(); if (instanceA == instanceB) { System.out.println("They are the same instance!"); } } }
标签:style blog color ar java sp div on log
原文地址:http://www.cnblogs.com/jingmoxukong/p/4015675.html