摘要: 一、饿汉式单例/** 单例模式* *//** 饿汉式单例模式* */class Singleton{ /* * 声明私有静态成员变量singleton。 * */ private static Singleton singleton = new... 阅读全文
posted @ 2018-12-03 13:17 问月晚安 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 一、简单工厂/** 简单工厂(静态工厂)* *//** 抽象产品类* */interface CarProduct{ /* * 抽象产品类的抽象方法show()。 * */ public void show();}/** 具体产品类* */cl... 阅读全文
posted @ 2018-12-03 11:50 问月晚安 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 一、定义装饰对象/** 定义一个装饰对象Person。* 包含一个方法feature()。* */class Person{ public void feature(){ System.out.println("I am a Person"); ... 阅读全文
posted @ 2018-12-03 10:42 问月晚安 阅读(101) 评论(0) 推荐(0) 编辑