第二十一章 单例模式

/**
 * Created by hero on 16-4-6.
 */
public class Singleton {
    
    public static Singleton getInstance() {
        return SingletonHolder.singleton;
    }

    private static class SingletonHolder {
        private static Singleton singleton = new Singleton();
    }

    private Singleton() {
    }
}
原文地址:https://www.cnblogs.com/littlehoom/p/5361435.html