子类能够继承父类封装的属性吗 谢谢大家

jy_developer 2014-08-21 11:20:21
子类能够继承父类封装的属性吗 在java中
...全文
498 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
小婷猪 2014-08-22
  • 打赏
  • 举报
回复
类的成员被声明为私有的是不能被这个类的子类继承。 只有类中被声明为保护的(protected)或者是共有的(public)的成员被在同一包中的子类继承除了被这个类声明的。(这翻译仅供参考,嘿嘿)
  • 打赏
  • 举报
回复
能,包括私有...只不过不能访问而已
ZangXT 2014-08-21
  • 打赏
  • 举报
回复
Java语言规范:http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.2 Members of a class that are declared private are not inherited by subclasses of that class. Only members of a class that are declared protected or public are inherited by subclasses declared in a package other than the one in which the class is declared. 英语不好,谁给翻译下?

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧