/** * 装饰者模式 * @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(); } } }
时间: 2024-10-04 04:05:07