在 interfaces
为什么方法访问说明符只有 public
为什么不protected
?
interface IPractice {
void test(); // it will be public
protected void test2(); // why this is not allowed
}
谁能给我解释一下吗?
最佳答案
接口(interface)的重点在于它向外界公开方法,因此可以隐藏实现细节。
界面内部发生的事情不应该被外界知道。
关于java - 为什么接口(interface)方法的作用域只是public?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16075223/