抽象类名作为形参和返回值

package com.daxing_01;

public class Cat {
public void eat() {
System.out.println("猫儿爱吃鱼!");
}
}

package com.daxing_01;
//操作类
public class CatOperator {
public void uesCat(Cat c){
c.eat();
}
}

package com.daxing_01;

public class CatDemo {
public static void main(String[] args) {
CatOperator co = new CatOperator();
Cat c = new Cat();
co.uesCat(c);
}
}
运行结果:

猫儿爱吃鱼!

Process finished with exit code 0

posted @ 2021-11-24 10:29  小风扇呜呜呜  阅读(31)  评论(0)    收藏  举报