摘要: 单例模式的目的:保证一个类仅有一个实例,并提供一个访问实例的全局访问点。要点:1、单例类拥有一个私有构造函数,确保用户无法通过new 关键字去直接实例化它。 2、单例模式包含一个静态私有成员变量与静态公用工厂方法。设计代码:public class Singleton{ private static Singleton instance=null; private Singleton(){ } public static Singleton getInstance(){ if(instance==null){ instance = new Singleto... 阅读全文
posted @ 2013-11-07 14:12 样_样 阅读(1662) 评论(0) 推荐(0)