DEV Community

sunj
sunj

Posted on

java, singleton

public class HolderSingleton {

    private HolderSingleton() {
    }

    public static HolderSingleton getInstance() {
        return Holder.instance;
    }

    private static class Holder {
        public static final HolderSingleton instance = new HolderSingleton();
    }
}
Enter fullscreen mode Exit fullscreen mode

Initialization-on-demand holder idiom 방식(holder에 의한 초기화 방식)

Top comments (0)