Java设计模式 装饰类
来源:互联网 发布:中国反倾销数据统计 编辑:程序博客网 时间:2024/06/03 21:25
装饰类经常出现在Java IO流中,
像BufferReader类就是InputStreamReader类的装饰类,还有很多例子
下面是一个简单的例子来帮助更好的理解 装饰类
package test;//通过SuperPerson装饰Person,增强了eat方法的功能class Person {public void eat() { //吃饭System.out.println("吃饭");}}class SuperPerson { //装饰类,装饰Person类,强化Person的功能Person p;public SuperPerson(Person p) {this.p = p;}public void eat() { //吃饭System.out.println("开胃菜");System.out.println("喝酒");p.eat();System.out.println("甜点");}}class Test {public static void main(String[] args) {Person p = new Person();SuperPerson sp = new SuperPerson(p);sp.eat();}}
0 0
- JAVA 装饰类(装饰设计模式)
- Java设计模式 装饰类
- Java装饰设计模式
- Java 装饰设计模式
- Java 装饰设计模式
- java 装饰设计模式
- Java 装饰设计模式
- java 装饰设计模式
- Java装饰设计模式
- Java 装饰设计模式
- Java装饰设计模式
- Java 设计模式 --装饰模式
- Java 设计模式-----装饰模式
- java设计模式-装饰模式
- java设计模式---装饰模式
- java设计模式-装饰模式
- 【Java设计模式】装饰模式
- java设计模式-装饰模式
- 利用ajaxFileupload实现表单和图片同时上传
- muduo日志3
- MySQL技术内幕-InnoDB存储引擎-读书笔记(一)
- sublime text2小技巧
- 12.The APR based Apache Tomcat Native library which allows optimal performance
- Java设计模式 装饰类
- VMware Workstation文件共享
- block里面的self要使用弱引用,否则会无法释放内存
- 13.警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ..
- 从DirectMemory谈谈Java NIO
- RT5350 I2C学习 -- 扫描所有的 I2C地址
- 14. 启动项目,服务器用的是resin 3.0 ,在启动的时候 ,eclipse的console中用红色的字体,
- JDK动态代理实现原理
- Redis 哈希对象