package com.plumage.designpattern;
/**
* @author 羽毛
* @description 单例设计模式 - 饿汉式
*/
public class MyHungrySingleton {
private MyHungrySingleton hungrySingleton;
private MyHungrySingleton() {
//私有构造方法
}
public MyHungrySingleton getInstance() {
if(null == hungrySingleton) {
hungrySingleton = new MyHungrySingleton();
}
return hungrySingleton;
}
}
设计模式 - 单例设计模式(饿汉式)
最新推荐文章于 2024-08-21 17:58:09 发布