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

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -