继承,父类与子类的问题
public class A {public static int y=0;
public int x=23;
public A(long x){
}
public A(int x){
this(new Long(x));
y=y+x;
}
public void f(int i, A o){}
public void f(long lo,A o){}
public void f(byte b,B o){}
}
public class B extends A{
int x=17;
public B(){
super(1);
new A(2);
x++;
}
public B(int x){
super(x);
y=x+1;
super.x=y+1;
}
public void f(int i,B o){}
public void f(long lo,B o){}
public void f(long lo,A o){}
}
public class C {
public static void main(String[] args) {
A aa1=new A(1L);
A aa2=new A(42);
B bb=new B();
A ab=new B(3);
int i=1;
long lo=2;
byte b=3;
ab.f(b, bb);
ab.f(lo, bb);
}
}
为什么最后 ab.f(lo, bb); 对应的是Class B里面 public void f(long lo,A o){} 这个方法? 求解答,谢谢!