Referrence:oracle Java Doc
Levels
Top Level:public, or package-private (no explicit modifier)
Member Level:public, private, Protected, package-private (no explicit modifier)
Three Modifiers & four Access Control Types
1. Public
A Class/member may being declared public
with the modifier, in which case, the class was visible to all classes everywhere .
2. Package-private (no explicit modifier)
If a class/member has no modifier (the default, also known as package-private), it's visible only within its OW N Package.
3. Private
The private
modifier specifies that the member can is only being accessed in its own class.
4. Protected
The protected
modifier specifies that the member can is only accessed within it own package (as with Package-pri Vate) and, in addition, by a subclass of their class in the another package.
Access levels Chart
1st Col:whether The class itself have access to the member defined by the access level.
2nd Col:whether classes in the same package as the class (regardless of their parentage) has access to the member.
3rd Col:whether Subclasses of the class declared outside This package has access to the member.
4th Col:whether All classes has access to the member.
Controlling Access in Java