/** * 装饰者模式 * @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-12-05 06:22:49