首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

单例模式-一

2012-12-18 
单例模式-1例模式 (Singleton),也叫单子模式 ,是一种常用的public class Singleton {private staticSingle

单例模式-1

例模式 (Singleton),也叫单子模式 ,是一种常用的public class Singleton { private static Singleton INSTANCE = new Singleton(); // Private constructor suppresses // default public constructor private Singleton() {} public static Singleton getInstance() { return INSTANCE; } }

?

?

?

??

?

?

?

public class Singleton { private static Singleton INSTANCE = null; // Private constructor suppresses // default public constructor private Singleton() {} public synchronized static Singleton getInstance() { if(INSTANCE==null) INSTANCE=new Singleton(); return INSTANCE; } }

?

?

?

?

?

?

?

热点排行