Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Java has four access levels and three access modifiers. There are only three modifiers because the default (what you get when you don’t use any access modifier) is one of the four access levels.
Access Levels (in order of how restrictive they are, from least to most restrictive)
Access modifiers
public protected private
Most of the time you’ll use only public and private access levels.
public
Use public for classes, constants (static final variables), and methods that you’re exposing to other code (for example getters and setters) and most constructors.
private
Use private for virtually all instance variables, and for methods that you don’t want outside code to call (in other words, methods used by the public methods of your class).