随笔分类 - 设计模式
摘要:public class FactoryTest { public static void main(String[] args) { Car a = new AudiFactory().getCar(); Car b = new BydFactory().getCar(); a.run(); b.
阅读全文
摘要:1.代理模式的定义 2. 静态代理模式举例 public class NetWorkTest { public static void main(String[] args) { Server server = new Server(); ProxyServer proxyServer = new
阅读全文
摘要:代码 // 模板方法模式 举例 public class BankTemplateMethod { public static void main(String[] args) { BankTemplate temp = new DrawMoney(); temp.process(); } } //
阅读全文
摘要://饿汉式 单例模式 class Bank{ //1.私有化类的构造器 private Bank() { } //2.内部创建类的对象 (类的实例) private static Bank bank = new Bank(); //3.提供公共的静态方法 , 返回类的对象 (注 :静态方法中只能调用
阅读全文
浙公网安备 33010602011771号