单例模式 延时加载
public class Singleton{
private static class SingletonLazyLoad {
static Singleton instance=new Singleton();//Singleton类定义实例对象,类名与实例名都可以自己定义
}
private Singleton(){}//隐藏构造器,不能通过new来实例化。
private static Singleton getInstance(){
return SingletonLazyLoad.instance;
}
}
posted on 2017-11-03 15:57 Jesseylove 阅读(318) 评论(0) 编辑 收藏 举报