在接口中受保护 [英] Protected in Interfaces
本文介绍了在接口中受保护的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么接口
定义中的所有方法都隐含 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屋!
查看全文