Overriding a super class's instance variables

后端 未结 9 1931
暗喜
暗喜 2020-11-30 07:47

Why are we not able to override an instance variable of a super class in a subclass?

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 08:12

    you can override a method,that is all right but what do you mean by overriding a variable? if you want to use a variable at any other place rather than super class u can use super. as in super(variable names); why do you want to override a variable? i mean is there any need?

提交回复
热议问题