为什么我在子类中修改父类的属性值,子类属性值也一同修改?
public class Fighter extends Card {
public Fighter(){
System.out.println("1 super role: " + super.role);
System.out.println("1 figher role:" + role) ;
role=3;
System.out.println("2 figher role:" + role) ;
System.out.println("2 super role: " + super.role);
}
}
输出结果为:
1 super role: 5
1 figher role:5
2 figher role:3
2 super role: 3
Fighter继承Card,我修改super.role的值,会导致子类的role值也改变???