Encapsulation is the process of wrapping the data (variables) and the code associated with those data (methods) within a single unit.
Encapsulation is used to hide the values or state of a structured data object inside a class, preventing direct access to them.
Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods.
To achieve encapsulation, the programmer declares the class variables as “private” and then provides what are called public “setter and getter” methods which make it possible to view and modify the variables
If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class.For this reason, encapsulation is also referred to as data hiding.
A class can have total control over what is stored in its fields.
The fields of a class can be made read-only or write-only.
The users of a class do not know how the class stores its data.
A class can change the data type of a field and users of the class do not need to change any of their code.
Encapsulation allows access to a level without revealing the complex details below that level.
The main benefit of encapsulation is the ability to modify implemented code without breaking the code of others who use our code.
Encapsulation gives maintainability, flexibility and extensibility to our code.
Nesta página do site você pode assistir ao vídeo on-line Encapsulation in java duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário ShreeHub 22 Abril 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 86 vezes e gostou 4 espectadores. Boa visualização!