高手帮帮忙 先谢谢了 看不懂(*^__^*) 嘻嘻……
interface Runner{public voic run();}
interface Swimmer{public void swim();}
abstract class Animal {abstract public void eat();}
class Person extends Animal implements Runner,Swimmer{
public void run(){System.out.println( "run ");}
public void swim(){System.out.println( "swim ");}
public void eat(){System.out.println( "eat ");}
}
public class TestInterface{
TestInerface t =new TestInterface();
Person p =new Person();
t.m1(p);//从这开始看不懂了 p不是对象吗?他当参数,传什么呢?
t.m2(p);
t.m3(p);
}
public void m1(Runner f){f.run();}//这也是一头雾水
public void m2(Swimmer s){s.swim();}
public void m3(Animal a){a.eat();}
我刚刚学java ,很喜欢,想更深入的学习了解,希望各位高手帮帮忙
先谢谢了
------解决方案--------------------晕 传递的是一个对象的引用
------解决方案--------------------看书看书...
把引用搞清楚..
------解决方案--------------------lz想想如果没有传入p的话,直接t.m1();会怎么样?也许就会想明白了