Monday, 9 May 2016

java - Isn't "package private" member access synonymous with the default (no-modifier) access?




I am a little confused over the term "package private" that some of the documentation uses, along with the usage of "default access." Aren't package-private and default access both synonymous with protected?


Answer



Yes, it's almost the same. The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...