接口的应用
适配器设计模式
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 {
@Override
public void show1() {
}
@Override
public void show2() {
}
@Override
public void show3() {
}
@Override
public void show4() {
}
}
InterImpl
package com.itheima.a09;
public class InterImpl extends InterAdapter{
// 用到哪个方法 就重新哪个
@Override
public void show2() {
System.out.println("只用第二个方法");
}
}
总结