标签:
class Singleton{ private static Singleton instance = new Singleton(); private Singleton(){ } public static Singleton getInstance(){ return instance; } public void print(){ System.out.println("Hello Word"); } } public class singleton { public static void main(String[] args) { // TODO 自动生成的方法存根 Singleton s1 = Singleton.getInstance(); Singleton s2 = Singleton.getInstance(); Singleton s3 = Singleton.getInstance(); s1.print(); s2.print(); s3.print(); } }
标签:
原文地址:http://www.cnblogs.com/tonglin0325/p/5196818.html