单例模式
public class SingletonTest
{
public static void main(String[] args)
{
Singleton singleton = Singleton.getInstance();
Singleton singleton2 = Singleton.getInstance();
System.out.println(singleton == singleton2);
}
}
class Singleton
{
private static Singleton singleton = new Singleton();
private Singleton()
{
}
public Singleton getInstance()
{
return singleton;
}
}