Difference and connection between aggregation and combination in JAVA, and difference between java aggregation and combination

Source: Internet
Author: User

Difference and connection between aggregation and combination in JAVA, and difference between java aggregation and combination

From JAVA programming-basics (8th)

Definition: one object can contain another object. The relationship between these two objects is called composition ).

A combination is actually a special form of clustering. Clustering simulates a (has-a) relationship, indicating the ownership relationship between two objects. The owner object in the ownership relationship is called the aggregation object, and its class is called the aggregating class ). The subordinate object in the attribution relationship is called the aggregated object, and its class is called the aggregated class ).

An object can be owned by several other clustering objects. If an object belongs to only one clustered object, the relationship between it and the clustered object is called composition ). For example, "one student has a name" and "one student has an address" is a clustering relationship because one address can be shared by several students.

In UML, solid diamond represents a combination, and hollow diamond represents a clustering relationship.

Clustering is usually represented as a data field in the clustering class,

Clustering can also exist between multiple objects in the same class. For example, a person may have one or more managers. One manager can be represented by variables, and multiple managers can use arrays,

Here, the relationship between aggregation and combination is self-evident.

 

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.