public class Test5 {
public static void main(String... args){
C o1 = new D();
o1.m(1.0,1.0);
o1.m(1.0f, 1.0f);
}
}
class C{
public void m(double x, double y) {
System.out.println("C' m(double,double)");
}
}
class D extends C{
public void m(float x, float y) {
System.out.println("D's m(float,float)");
}
}
why the output is
C' m(double,double)
C' m(double,double)
for o1.m(1.0f, 1.0f);
I think it will call public void m(float x, float y)
in class D
, I don't understand why it is determined by the declaration type instead of reference type