interface A{
void run();
void hitMan();
void sayHi(String name,String color,int num);
}
class Car{
public void show(A a){
a.run();
a.hitMan();
a.sayHi("benz","red",73);
}
}
public class L{
public static void main(String[] args) {
Car car=new Car();
car.show(new A() {
@Override
public void run() {
System.out.println("car can run!!");
}
@Override
public void hitMan() {
System.out.println("car can hitMan");
}
@Override
public void sayHi(String type,String color,int num) {
System.out.println("type:"+type);
System.out.println("color:"+color);
System.out.println("num:"+num);
}
});
}
}
学习过程4
最新推荐文章于 2022-02-25 23:12:19 发布