java 类的适配器设计

/*
 * 适配器设计
 * 因为采用了适配器中间环节,子类就不需要实现接口中的全部方法
 * 图形界面编程的事件处理事件中经常使用此种设计模式
 */
package com.classes;
public class adapter extends theAdapter{
    public static void main(String[] args){
        window wd = new window();
        wd.open();
    }
}
interface inter{
    public  void open();
    public void start();
    public void close();
}
//抽象类实现接口,覆写所以方法,但方法体为空
abstract class theAdapter implements inter{
    public void open(){
    }
    public void start(){
    }
    public void close(){
    }
}
class window extends theAdapter{
    public   void open(){
        System.out.println("open!");
    }
}


你可能感兴趣的:(java,abstract,package,interface,适配器)