// super与this关键字图解
public class Fu {
int num = 10;
public void method() {
System.out.println("父类方法");
}
}
public class Zi extends Fu {
int num = 20;
@Override
public void method() {
super.method(); // 调用了父类方法
System.out.println("子类方法");
}
public void show() {
int num = 30;
System.out.println(num); // 30
System.out.println(this.num); // 20
System.out.println(super.num); // 10
}
}
public class Demo {
public static void main(String[] args) {
Zi zi = new Zi();
zi.show();
zi.method();
}
}