设计模式之禅-单例模式

单例模式:

  Ensure a class has only one instance and provide a global point og access to it.

  


public class Singleton {

  private static final Singleton SINGLETON = new Singleton();

  private Singleton(){

  }

  public static Singleton getSingleton(){
    return SINGLETON;
  }

  public static void dosomething(){
    //其他方法,尽量是static
  }
}

posted @ 2012-06-10 11:11  风叉叉  阅读(143)  评论(0编辑  收藏  举报