Understanding the encapsulation of one of the object-oriented features

Source: Internet
Author: User

What is encapsulation?

Encapsulation is the core idea of object-oriented programming, which encapsulates the properties and behaviors of objects, while the carriers that encapsulate the properties and behaviors of objects are classes, which often hide their implementation details from the customer, which is the idea of encapsulation.

For example, the user can use the computer, just tap the keyboard to achieve a number of functions, users do not need to know how the computer is working, even if the user may happen to know how the computer works, but the use of the computer does not rely entirely on the details of how the computer works.

The idea of encapsulation ensures the integrality of the internal data structure, avoids the external influence on the internal information, and improves the maintainability of the program.


The package I understand--literally--wraps up the east suit. It is embodied in:

In a Java program, the property is set to private, which is the embodiment of a package that encapsulates the data to avoid external (outside of this class) access;

The property and behavior of the object is encapsulated, and the class is the carrier, which is also the embodiment of encapsulation, that is, class and class is also a kind of encapsulation;

Package and package is also the embodiment of a package;

Between engineering and engineering is also a package.


Understanding the encapsulation of one of the object-oriented features

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.