Inheritance, encapsulation, polymorphism are the three main features of Java. Make a note of the learning package today.
How to understand encapsulation? Encapsulation is literally to be sealed up, that is, to hide the information, refers to the use of abstract data types to encapsulate data and data-based operations together to form an indivisible independent entity, the data is protected in the abstract data type inside, as far as possible to hide the internal details, Only some external interfaces are retained to make them contact external.
The benefits of encapsulation include the following four points:
1, good package can reduce the coupling.
2, the structure within the class can be freely modified.
3, the member can be more precise control.
4, hidden information, implementation details.
In fact, these four points are bound together. How to understand it, the main purpose of encapsulation is to reduce the coupling between objects and objects. In the Great Leap Forward era, general, we all get together to eat, tune the truth we all understand, the taste of the pot change, everybody all have to bear, extremely not free. And the back of the household responsibility system, each Spacerl, home to cook the rice, the taste of the pot is not the same, so that more freedom, the taste of rice can be more precise control of the other people will not have too much impact on the taste of their own rice, and how to do other people do not know. To contact the time, open a door, welcome others to eat, others will know your taste, so that the realization of the interaction.
Packaging for Java