2. Access Control

Java’s access control mechanisms allow you to control dependences.

In the text of a class, you can indicate which other classes can have dependences on it, and to some extent you can control the nature of the dependences.

A class declared as public can be referred to by any other class; otherwise, it can be referred to only by classes in the same package. So by dropping th s modifier, we can prevent dependences on the class from any class outside the package.

Members of a class (fields and methods) may be:

Modifiers on members of B allow us to control the nature of dependence by changing which members belong to B‘s specification.