ENCAPSULATION IN JAVA

What is Encapsulation?

                                         encpsulation in java

Encapsulation is the technique of making the fields in a class private and providing access to the fields through public methods. Encapsulation is also called as data hiding.
 
The benefits of encapsulation:
The ability to modify our implemented code without breaking the code of others who use our code.
Encapsulation gives maintainabilty,flexibilty, and extensibility to our code.
The fields of a class can be made read-only or write-only.
A class can have total control over of what is stored in its fields.
A class can change the data type of a field, and users of the class do not need to the changes any of theircode.