0
点赞
收藏
分享

微信扫一扫

接口定义与实现

鱼板番茄 2022-01-06 阅读 51
java
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();
	}
}
举报

相关推荐

0 条评论