public class Person{
private Person(){}
public static Person getInstance(){
return PersonHolder.mInstance;
}
private static class PersonHolder{
private static final Person mInstance=new Person();
}
}
public class Person{
private Person(){}
public static Person getInstance(){
return PersonHolder.mInstance;
}
private static class PersonHolder{
private static final Person mInstance=new Person();
}
}
本文标题:静态内部类-单例模式
本文链接:https://www.haomeiwen.com/subject/wwtqkftx.html
网友评论