5月15日 CMS 周二

package com.www.one;

public class Singleton {
    //饿汉式
    private static Singleton instance = new Singleton();

    private Singleton(){

    };

    static Singleton getinstance(){
        return instance;
    }
}
package com.www.two;

public class Singleton {
    private static Singleton instance = null;
    private Singleton(){

    };
    static Singleton getinstance(){
        if(instance==null)
            instance = new Singleton();
        return instance;
    }
}

人非人不济,马非马不走,土非土不高,水非水不流。
[译文]人没有别人的帮助就不能成功,马离开马群就很难奔驰,土堆不增添新土就不再增高,水不增加新水就不会流动。

——曾子 《大戴礼记·曾子制言上》

猜你喜欢

转载自blog.csdn.net/helloworld_1996/article/details/80330570