class SingleTon{
}
class SingleTon1{
private SingleTon1(){
}
public static SingleTon instance = new SingleTon1();
}
class SingleTon2{
private SingleTon2(){
}
private static SingleTon2 instance;
public static SingleTon2 getInstance() {
if (instance == null) {
instance = new SingleTon2();
}
return instance;
}
}
原文:http://www.cnblogs.com/starlitnext/p/4092988.html