本帖最后由 sapolang02 于 2016-8-7 10:10 编辑
饿汉式
class Person{
Private static Person p=new Person();
private Person(){}
public static Person getInstance(){
return p; }
}
懒汉式
class Person{
private Person p=null;
private Person(){}
public static Person getInstance(){
p=new Person();
return p;
}
}
写的有点简单,凑合着看
|