class Base
{
int x=1;
void show()
{
System.out.println(x);
}
}
class Child extends Base
{
int x=2;
public static void main(String s[])
{
Child c=new Child();
c.show();
}
}
输出为1 的方法显示在基类,但继承优先级应给予局部变量,因此输出应该是2或者是它的编译器之前,它隐含的前缀超? ?爪哇 - 继承
多态性并不适用于各个领域。 –