62,615
社区成员
发帖
与我相关
我的任务
分享
public class A {
public int m = 1;
public void view() {
System.out.println(this.m);
}
}
class B extends A {
public int m = 2;
public static void main(String[] args) {
B b = new B();
System.out.println(b);
b.view();
}
}
test.B@6ca6fed5
1
因为你的B没有重写view,调用的还是A的view