Access control
Default accessibility means access is permitted from any method in any class that is a member of the same package. A protected method or variable is accessible from any method in any class that is a member of the same package, and also from any method in any subclass.
|
Access
modifier
keywords
|
Accessible to:
|
|||
| Same class | Class in same package (folder) | Subclass in different package | Non-subclass in different package | |
| public | YES | YES | YES | YES |
| protected | YES | YES | YES | NO |
| [NONE: DEFAULT] |
YES | YES | NO | NO |
| private | YES | NO | NO | NO |
public - totally accessible
protected - package or subclass ok
default - package ok
private - same class only