适配器模式
来源:互联网 发布:win10解压缩软件 编辑:程序博客网 时间:2024/06/01 10:38
适配器模式(Adapter):将一个类的接口转换成客户希望的另外一个接口。Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。
下面是Adapter结构图:
下面演示一个简单的Demo:
Target类:
public class Target {public void request() {System.out.println("一般");}}
Adaptee类:
public class Adaptee {public void specificRequest() {System.out.println("特殊");}}
Adapter类:
public class Adapter extends Target{private Adaptee adaptee = new Adaptee();@Overridepublic void request() {adaptee.specificRequest();}}
客户端:
public class Client {public static void main(String[] args) {Target target = new Adapter();target.request();}}
- 适配器及适配器模式
- 适配器及适配器模式
- 适配器模式(类适配器)
- 适配器模式(默认适配器)
- 适配器模式(对象适配器)
- 适配器模式-类适配器
- 适配器模式-对象适配器
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- java 对数组进行插入删除修改
- 寻找正在连接中的网络连接,并开启网络连接的网络连接共享功能
- uva 10400 Game Show Math
- Android中获取应用程序(包)的信息-----PackageManager的使用(一)
- Android display架构分析
- 适配器模式
- 安卓开发32:Paint 画笔
- 免费 开发资源库 android web
- 裁剪空间法--实现细节
- java反射机制
- Category(范畴)的使用方法与介绍
- UVA 10954 Add All 全加一起 模拟+贪心+优先队列
- GBK与GB2312
- 获取加载Kernel32.dll的地址