java - Protected access modifier -
jls 6.6.2 gives following restriction package-access of protected members.
a protected member or constructor of object may accessed outside package in declared code responsible implementation of object.
what did mean responsible implementation. couldn't example?
it means can't access protected super-class member of different instance of same class.
package one; public class {protected int b;} package two; public class b extends { public void somemethod (a other) { b = 5; // allowed other.b = 5; // not allowed } }
Comments
Post a Comment