/**
* 汽车接口
* @author Administrator
*
*/
public interface ICar {
// 抽象方法
public abstract void driver();
}
/**
* 卡车类
* @author Administrator
*
*/
public class Truck implements ICar{
@Override
public void driver() {
System.out.println("卡车正在载货...");
}
}
/**
* 吊车类
* @author Administrator
*
*/
public class Crane implements ICar{
@Override
public void driver() {
System.out.println("吊车正在吊货...");
}
}
/**
* 测试类
* @author Administrator
*
*/
public class TestCar {
public static void main(String[] args) {
// 接口回调
// 卡车对象
ICar iCar = new Truck();
iCar.driver();
// 吊车对象
iCar = new Crane();
iCar.driver();
}
}