标签:
package com.war3; public class Singleton { private static final Singleton singleton = new Singleton(); private Singleton(){} public static Singleton getInstance(){ return singleton; } }
package com.war3; public class Test { public static void main(String[] args) { Singleton s1= Singleton.getInstance(); Singleton s2= Singleton.getInstance(); System.out.println(s1==s2);//true } }
标签:
原文地址:http://www.cnblogs.com/build-up/p/5044014.html