/** * 功能:单列模式 * @author Administrator * */ public class SingletonTest { public static void main(String[] args) { Singleton test1 = Singleton.getInstance(); Singleton test2 = Singleton.getInstance(); System.out.println(test1 == test2); } } class Singleton { private static Singleton singleton = new Singleton(); private Singleton() { } public static Singleton getInstance() { return singleton; } }