Class Association and association

Source: Internet
Author: User

Class Association and association

Several relationships in a UML class diagram:

1. Association

(1) the association relationship is the connection between the class and the class, which makes one class know the attributes and methods of the other class.
(2) the association can be bidirectional or unidirectional. Two-way association can have two arrows or no arrows, and one-way Association has one arrow.
(3) In Java or c ++, associations are implemented by using member variables.

Class A {} class B {public A a {get; set ;}}

Note:You can use attributes to know the attributes and methods of another class instance.


1. An aggregation relationship is a strong association relationship.
2. Aggregation is the relationship between the whole and the part. For example, an automobile consists of an engine, a tire, and other parts.
3. The aggregation relationship is also implemented through member variables. However, the two classes involved in the Association are at the same level, while the two classes in the aggregation relationship are at different levels. One Class represents the whole, and the other class represents the part.
4. Association and aggregation cannot be distinguished only from Java or C ++ syntax, and the logical relationship between classes involved must be investigated.


Related Article

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: 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.