单例模式

public class Dog {
    static Dog d ;
    
    private Dog() {
        
    }
    public static Dog getDog() {
        if(d == null)
            return d = new Dog();
        return d;
    }
}

 

posted @ 2019-06-04 10:49  小小超plus  阅读(106)  评论(0编辑  收藏  举报