interface Flyable{
void Fly();
}
class Bird implements Flyable{
public void Fly(){
System.out.println("鸟可以飞");
}
}
class Plane implements Flyable{
public void Fly(){
System.out.println("飞机可以飞");
}
}
public class Text{
public static void main(String[] args){
Flyable ifly=new Bird();
ifly.Fly();
ifly=new Plane();
ifly.Fly();
}
}
接口定义与实现
最新推荐文章于 2024-09-15 19:46:31 发布