第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

類適配器模式 的理解

類適配器模式 的理解

Rvie 2017-12-22 11:39:11
// 已存在的、具有特殊功能、但不符合我们既有的标准接口的类  class Adaptee {      public void specificRequest() {          System.out.println("被适配类具有 特殊功能...");      }  }  // 目标接口,或称为标准接口  interface Target {      public void request();  }  // 具体目标类,只提供普通功能  class ConcreteTarget implements Target {      public void request() {          System.out.println("普通类 具有 普通功能...");      }  }   // 适配器类,继承了被适配类,同时实现标准接口  class MyAdapter extends Adaptee implements Target{      public void request() {          super.specificRequest();      }  }   // 测试类  public class Client {      public static void main(String[] args) {          // 使用普通功能类          Target concreteTarget = new ConcreteTarget();          concreteTarget.request();          // 使用特殊功能类,即适配类          Target adapter = new MyAdapter();          adapter.request();      }  }  测试结果: 普通类 具有 普通功能... 被适配类具有 特殊功能... 想问一下 // 使用普通功能类          Target concreteTarget = new ConcreteTarget();          concreteTarget.request();          // 使用特殊功能类,即适配类          Target adapter = new MyAdapter();          adapter.request();  这四句话怎么理解,可以解释一下吗,谢谢啦 是关于类的适配器模式不是对象适配器模式哦~
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關(guān)注
  • 1183 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號