接口的应用
适配器设计模式
Inter
package com.itheima.a09;public interface Inter {public abstract void show1();public abstract void show2();public abstract void show3();public abstract void show4();}
InterAdapter
package com.itheima.a09;
//抽象
public abstract class InterAdapter implements Inter {@Overridepublic void show1() {}@Overridepublic void show2() {}@Overridepublic void show3() {}@Overridepublic void show4() {}
}
InterImpl
package com.itheima.a09;public class InterImpl extends InterAdapter{
// 用到哪个方法 就重新哪个@Overridepublic void show2() {System.out.println("只用第二个方法");}
}
总结