【发布时间】:2018-04-19 00:17:31
【问题描述】:
我是 Java 新手,我不明白为什么在 c3.java 中我在 ref.x=1 中出现错误。 x 被声明为受保护的属性,因此从 c1 继承的类的方法应该能够使用 c1 类型的任何对象的任何 x。那怎么错了? enter image description here
【问题讨论】:
-
什么方法?
C4不继承任何东西。为什么它应该有权访问另一个类的受保护成员?
标签: java attributes parameter-passing