In this Java tutorial, you will learn about the object oriented concept of Encapsulation, and how encapsulation is implemented in Java, with examples.
Encapsulation in Java
Encapsulation is a technique of hiding the variables of a class from other classes, and giving access to them only through methods(setters and getters). Hence, Encapsulation in Java language means binding the data (variables) with the code(methods – setters and getters). In this tutorial, we shall learn the intuition and realization of encapsulation in Java language with example programs.
The below diagram gives an idea about Encapsulation in Java
