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 - 开发者_运维百科
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 ?
Protected method can be accessed from subclasses. Make that method public if you want to access from any class. See details here
Also as mentioned by @Sean Patrick Floyd, from classes in the same package!
精彩评论