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

知识点:

1、子类重写父类方法时,不能使用比分类中被重写的方法更严格的访问权限,如父类中的方法是public时,子类的方法就不能是prvate。

2、因为接口定义的方法默认是public的,意思就是你没有任何访问修饰符的情况下,系统给接口的方法加上了一个public的访问修饰符。

3、类的默认访问修饰符是freidnly,访问级别比public低,

错误原因:类继承接口,在重写接口方法时,没有用public定义

 

参考:https://zhidao.baidu.com/question/48781162.html

https://blog.csdn.net/u014683488/article/details/39119463

posted @ 2019-05-13 20:14  甜汤  阅读(2871)  评论(0编辑  收藏  举报