Parent.java
@Data
public class Parent {
private int size = -1;
public void printSize() {
System.out.println(getSize());
}
public void printSize2() {
System.out.println(size);
}
}
Son.java
@Data
public class Son extends Parent {
private int size = 15;
public static void main(String[] args) {
Son s = new Son();
s.printSize(); // 15
s.printSize2(); // -1 访问父类的size属性
}
}