首页 > 代码库 > protected

protected

protected access requires a little more elaboration. 
Suppose class A declares a protected field x and is extended by a class B, which is defined in a different package (this last point is important). Class B inherits the protected field x, and its code can access that field in the current instance of B or in any other instances of B that the code can refer to. 
 
This does not mean, however, that the code of class B can start reading the protected fields of arbitrary instances of A
 
《java in a nutshell》

protected