首页 > 其他 > 详细

[20-05-30][Design Model 6]ADAPTER 1

时间:2020-05-30 17:41:07      阅读:53      评论:0      收藏:0      [点我收藏+]
1 package test_24_1;
2 
3 public interface Target {
4 
5     public void method1();
6     
7     public void method2();
8 }

 

1 package test_24_1;
2 
3 public class Adaptee {
4 
5     public void method1() {
6         
7         System.out.println("Adaptee method1()");
8     }
9 }

 

 1 package test_24_1;
 2 
 3 public class Adapter extends Adaptee implements Target {
 4 
 5     @Override
 6     public void method2() {
 7 
 8         System.out.println("Adapter method2()");
 9     }
10 
11 }

 

 1 package test_24_1;
 2 
 3 public class AdapterTest {
 4 
 5     public static void main(String[] args) {
 6         
 7         Adapter adapter = new Adapter();
 8         
 9         adapter.method1();
10         
11         adapter.method2();
12     }
13 }

 

结果如下:

Adaptee method1()
Adapter method2()

[20-05-30][Design Model 6]ADAPTER 1

原文:https://www.cnblogs.com/mirai3usi9/p/12993432.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!