Packages and Member Access
The preceding chapters have introduced the fundamentals of access control, including the private and public modifiers, but they have not told the entire story. The reason for this is that packages also participate in Java’s access control mechanism, and a complete discussion had to wait until packages were covered.
The visibility of an element is determined by its access specification—private, public, protected, or default—and the package in which it resides. Thus, the visibility of an element is determined by its visibility within a class and its visibility within a package. This multilayered approach to access control supports a rich assortment of access privileges. Table 8-1 summarizes the various access levels. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access