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》
posted @ 2016-10-12 15:41  okay4321  阅读(229)  评论(0编辑  收藏  举报