设计模式——单例模式

单例模式有很多种,个人习惯使用如下方式:

//记事本 手写,未必能编译通过哦
public class Single {
    private static class Holder{
        static final Single instance = new Single();
    }
    public static Single getInstance(){
        retuen Holder.instance;
    }    
    private Single(){
    }
}
原文地址:https://www.cnblogs.com/tengpan-cn/p/8280473.html