单例设计模式
来源:互联网 发布:产品模型数据交换标准 编辑:程序博客网 时间:2024/06/05 15:18
梳理梳理一下自己的IT知识,开始写写博客,无论别人有没有写过,
//懒汉式
public class SinglePattern {
//声明一个静态的私有对象
privatestatic SinglePatternsinglePattern =null;
//私有的构造方法,防止外部类new对象
private SinglePattern(){
System.out.println("已创建");
}
public static SinglePattern getInstance(){
if(singlePattern ==null){
singlePattern =new SinglePattern();
return singlePattern;
}
return singlePattern;
}
public void printMessage(){
System.out.println("信息已打印");
}
}
阅读全文
0 0
- 设计模式--单例
- 单例设计模式
- 设计模式----单例
- 单例设计模式
- 单例设计模式
- 单例设计模式
- 单例设计模式
- 单例设计模式
- 单例设计模式
- 单例设计模式
- 设计模式-单例
- 单例设计模式
- 单例设计模式
- 单例设计模式
- 单例设计模式
- 单例设计模式
- 单例设计模式
- 单例设计模式
- 十大编程算法助程序员走上高手之路
- ZooKeeper概述
- 理解 Python 装饰器看这一篇就够了
- 自定义FormAuthentia
- windows charles 移动APP抓包
- 单例设计模式
- 可拔插视图
- Linux权限部分
- 启用企业级空间地理数据库
- 接口测试工具Postman之二---工具介绍
- 项目发布过程的问题随笔(很傻很天真的问题)
- .c文件生成.cgi文件
- javascript中的location对象属性及描述。
- 【2017.11.15】文件管理