Access Control
- Java has four levels of controlling access to fields, methods, and classes:
- public access
- Can be accessed by methods of all classes
- private access
- Can be accessed only by the methods of their own class
- protected access
- package access
- The default, when no access modifier is given
- Can be accessed by all classes in the same package
- Good default for classes, but extremely unfortunate for fields