摘要:
##单例模式 单例模式分为饿汉式和懒汉式,通过构造方法私有化,类内部提供static方法获取实例化对象,这样不管外部如何操作永远都只有一个实例化对象 ###饿汉式: class Singleton { private static final Singleton INSTANCE = new Sin 阅读全文
posted @ 2020-09-07 23:05
颉颃
阅读(173)
评论(0)
推荐(0)
摘要:
##代理模式: interface IBuy { public void buy(); } class RealBuyer implements IBuy { @Override public void buy() { System.out.println("2、购物消费"); } } class 阅读全文
posted @ 2020-09-07 18:52
颉颃
阅读(169)
评论(0)
推荐(0)
摘要:
##简单工厂模式: interface IShape { public void draw(); } class Circular implements IShape { @Override public void draw() { System.out.println("圆形"); } } cla 阅读全文
posted @ 2020-09-07 14:41
颉颃
阅读(157)
评论(0)
推荐(0)

浙公网安备 33010602011771号