java 什么是从另一个对象访问的受保护方法访问级别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6705423/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is protected method access level with regard to accessing from another object
提问by blue-sky
I'm passing an object reference to a Util class. I'm attempting to invoke a protected method on the Util class but I getting a compile time error -
我将对象引用传递给 Util 类。我试图在 Util 类上调用受保护的方法,但出现编译时错误 -
The method setPositionChild(Field, int, int) from the type Manager is not visible
To invoke a protected method is it required to be in the implementing class only ? Can I not pass the reference to an external class and invoke the reference from there ?
要调用受保护的方法是否只需要在实现类中?我不能将引用传递给外部类并从那里调用引用吗?