单例类
来源:互联网 发布:w10无法连接到这个网络 编辑:程序博客网 时间:2024/06/05 17:40
public class Singleton
{
private static Singleton obj = null;
public static Singleton getInstance()
{
if(null == obj)
{
obj = new Singleton();
}
return obj;
}
public static void main(String[] args)
{
Singleton obj1 = Singleton.getInstance();
Singleton obj2 = Singleton.getInstance();
System.out.println(obj1 == obj2);
}
}
{
private static Singleton obj = null;
public static Singleton getInstance()
{
if(null == obj)
{
obj = new Singleton();
}
return obj;
}
public static void main(String[] args)
{
Singleton obj1 = Singleton.getInstance();
Singleton obj2 = Singleton.getInstance();
System.out.println(obj1 == obj2);
}
}
- 单例类
- 单例类
- 单例类
- 单例类
- 单例类
- 单例类
- 单例类
- 单例类
- 单例类
- 单例类。
- 单例类
- 单例类
- 单例类
- 单例类
- 单例类
- 单例类
- 单例类
- 单例类
- UltraEdit使用技巧
- web.xml不认<taglib>解决办法
- 改变Xcode自动生成的公司名
- Junit指定运行的测试方法
- MRS,MSR指令详解
- 单例类
- vc-询问简单的问题 。
- iphone NSString/NSData/char*转换
- define关键字
- 地震之后的白宫(视频),也许奥巴马的办公室并不比县长办公室大
- Certificate identity appearing twice与dwarfdump binary must exist
- 20110831
- MySQL---Windows环境下从命令行进入MySQL命令行程序
- COM笔记-QueryInterface函数