DecoratorPattern(装饰器模式)
/**
* 装饰者模式
* @author TMAC-J
* 总的来说,装饰者模式就是继承的应用
*/
public class DecoratorPattern {
interface Beans{
void doSomething();
}
public class MyBean implements Beans{
@Override
public void doSomething() {
System.out.println("doSomething...");
}
}
public class DecoratorMyBean extends MyBean{
public void doMoreThing(){
System.out.println("doOtherthing...");
doSomething();
}
}
}

浙公网安备 33010602011771号