Access Modifiers
An access modifier limits the scope of visibility of a class, variable, or method. A class will not compile with code including an identifier that is not visible to the class (whose scope omits the class). The following table lists the access modifiers in increasing order of scope size:
| Access Modifier | Applies to | Scope of Visibility |
private |
variable method |
Its own class |
| omitted - default (package access) |
variable method class |
Classes in the package containing its own class |
protected |
variable method |
Classes in the package containing its own class Subclasses of its own class contained in any package |
public |
variable method class |
All classes in all packages |