首页 > 其他 > 详细

编译错误:Cannot reduce the visibility of the inherited method from Object

时间:2021-05-11 16:52:52      阅读:10      评论:0      收藏:0      [点我收藏+]

编译错误:Cannot reduce the visibility of the inherited method from Object
解释:子类重写父类方法时,访问权限不可更严格,权限从小到大为:private->friendly->protected->public
例:class A{ protected String toString() { return super.toString(); } }
toString 是源自java Object类,因为它是object里面已经有了的方法,而所有类都是继承object,所以“所有对象都有这个方法”,
Object类默认以public继承,所以toString的访问权限不能从public->protexted。

编译错误:Cannot reduce the visibility of the inherited method from Object

原文:https://www.cnblogs.com/atri-my-dear-moments-/p/14753821.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!