What is a secure access level to a method for accessing another object

I pass the object reference to the Util class. I try to call a protected method in the Util class, but I get a compile-time error -

The method setPositionChild(Field, int, int) from the type Manager is not visible 

To call a protected method, is it required only in the implementation class? Can I pass the link to an external class and call the link there?

+4
source share
1 answer

The protected method can be accessed from subclasses. Make this method public if you want to access from any class. More here

Also, as @Sean Patrick Floyd mentioned, from classes in one package!

+7
source

All Articles