1、装饰者模式与代理模式 (静态代理) 

 在日常开发里面,我们经常需要给某个类的方法增加加某些特定的功能。

       例如:有婴儿,婴儿会吃饭和走动,如以下类

 1 package com.scl.designpattern.proxy;
 2 
 3 //婴儿类
 4 public class Child implements Human
 5 {
 6     public void eat()
 7     {
 8         System.out.println("eat something....");
 9     }
10 
11     @Override
12     public void run()
13     {
14         System.out.println("Child run very slow");
15     }
16 }
婴儿类

相关文章:

  • 2021-05-16
  • 2021-12-18
  • 2021-08-03
  • 2021-11-26
  • 2022-01-20
  • 2021-09-30
  • 2021-12-01
  • 2021-12-01
猜你喜欢
  • 2021-06-12
  • 2021-12-24
  • 2021-09-27
  • 2021-10-22
  • 2021-04-24
相关资源
相似解决方案