【Java学习】-protected

If you created a new package and inherit from a class in another package, the only members you have access to are the public members of the original package.

Sometimes the creator of the base class would like to take a particular member and grant access to derived classes but not the world in general. That's what protected does. protected also gives package access--that is, other classes in the same package may access protected elements.

posted @ 2022-02-17 10:15  易点灵通  阅读(75)  评论(0)    收藏  举报