Search code examples
javaterminologyprotectedaccess-modifierspackage-private

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?


Solution

  • 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.