Encapsulation in java

Publicado el: 22 abril 2020
en el canal de: ShreeHub
86
4

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.


En esta página del sitio puede ver el video en línea Encapsulation in java de Duración hora minuto segunda en buena calidad , que subió el usuario ShreeHub 22 abril 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 86 veces y le gustó 4 a los espectadores. Disfruta viendo!