java test.test(new Bird(){ 这句是什么意思
publicabstractclassBird{privateStringname;publicStringgetName(){returnname;}publicvoi...
public abstract class Bird {
private String name;
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
public abstract int fly();
}
public class Test{
public void test (Bird bird){
System.out.println(bird.getName()+"能够飞"+bird.fly()+"米");
}
public static void main(String[] args) {
Test.test=new Test();
test.test(new Bird(){
public int fiy(){
return 10000;
}
public String getName(){
return "大雁";
}
});
}
} 展开
private String name;
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
public abstract int fly();
}
public class Test{
public void test (Bird bird){
System.out.println(bird.getName()+"能够飞"+bird.fly()+"米");
}
public static void main(String[] args) {
Test.test=new Test();
test.test(new Bird(){
public int fiy(){
return 10000;
}
public String getName(){
return "大雁";
}
});
}
} 展开
1个回答
2017-05-20
展开全部
test.test(new Bird())
调用test对象的test方法、并传递一个Bird的实例
~~~~~~~~~~
调用test对象的test方法、并传递一个Bird的实例
~~~~~~~~~~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询