受接口保护 [英] Protected in Interfaces
本文介绍了受接口保护的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么interface
定义中的所有方法都隐含地public
?为什么它不允许使用 protected
方法?
Why are all methods in an interface
definition implicitly public
? Why does it not allow a protected
method?
推荐答案
因为界面应该意味着你可以从课堂之外看到什么".添加非公共方法是没有意义的.
Because an interface is supposed to mean "what you can see from outside the class". It would not make sense to add non-public methods.
这篇关于受接口保护的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文