设计模式(七单例模式)

设计模式(七单例模式)

public class Singleton

{

private static Singleton instance=null;  //静态私有成员变量

//私有构造函数

private Singleton()

{

}

 

       //静态公有工厂方法,返回唯一实例

public static Singleton getInstance()

{

if(instance==null)

    instance=new Singleton();

return instance;

}

}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-15
  • 2021-06-02
  • 2021-12-31
猜你喜欢
  • 2021-05-27
  • 2021-09-13
  • 2021-12-15
  • 2021-08-01
  • 2021-12-10
相关资源
相似解决方案