我有以下代码,我不明白为什么这段代码的输出是:“high high”。在我看来,输出必须是:“Low Out”
public class A{
private String runNow(){
return "High";
}
static class B extends A{
public String runNow(){
return "Low";
}
}
public static void main(String args[]){
A[] a=new B[]{new B(),new C()};
for(A aa:a)
System.out.print(aa.runNow()+" ");
}
}
class C extends A.B{
public String runNow(){
return "Out";
}
}