}
2、Adaptee
需要适配的类。
package designMode.adapter.sxn;
public class Adaptee {
public void specificRequest() {
System.out.println(“特殊请求”);
}
}
3、Adapter
通过在内部包装一个Adaptee对象,把源接口转换成目标接口。
package designMode.adapter.sxn;
public class Adapter extends Target{
private Adaptee adaptee = new Adaptee();
@Override
public void request() {
adaptee.specificRequest();
}
}
4、测试类
package designMode.adapter.sxn;
public class Client {
public static void main(String[] args) {
Target target = new Adapter();
target.request();
}
}
5、控制台输出
</