/**
* 单例模式。饿汉式
*/
public class Singleton {
private static Singleton instance = new Singleton();
/**
* 私有化构造函数
*/
private Singleton() {
}
public static Singleton getInstance() {
return instance;
}
}
单例设计模式(恶汉式)
最新推荐文章于 2020-04-16 10:20:50 发布