package zuo.da.zu;
interface Ifly {
void flying();
}
class Plane implements Ifly{
private String name;
public Plane(String name) {
this.name = name;
}
public void start() {
System.out.println(this.name + "正在启动!");
}
public void flying(){
System.out.println("发动机正常启动," + this.name + "正在飞行!");
}
}
public class Demo {
public static void testFly(Ifly f){
f.flying();
}
public static void main(String[] args){
testFly(new Plane("中国国产飞机C919"));
}
}
输出为
发动机正常启动,中国国产飞机C919正在飞行!