单例模式你 静态内部类

class Singleton {
    private static class SingletonInstance {
        private static final Singleton INSTANCE = new Singleton();
    }

    private Singleton() {
    }

    public static Singleton getInstance() {
        return SingletonInstance.INSTANCE;
    }
}

 

posted on 2022-04-14 11:57  金满仓  阅读(12)  评论(0编辑  收藏  举报

导航