Prerequisite – Association, Composition and Aggregation in Java
An association is defined as an organization of people with a common purpose and having a formal structure. It represents a binary relationship between two objects that describes an activity. It is a relationship between objects. For example, A doctor can be associated with multiple patients.
An aggregation is a collection, or the gathering of things together. This relationship is represented by a “has a” relationship. In other words, aggregation is a group, body, or mass composed of many distinct parts or individuals For example, phone number list is an example of aggregation.
Difference between Aggregation and Association:
|Aggregation describes a special type of an association which specifies a whole and part relationship.||Association is a relationship between two classes where one class use another.|
|It in flexibile in nature||It is inflexible in nature|
|Special kind of association where there is whole-part relation between two objects||It means there is almost always a link between objects|
|It is represented by a “has a”+ “whole-part” relationship||It is represented by a “has a” relationship|
|Diamond shape structure is used next to the assembly class.||Line segment is used between the components or the class|
- Difference between MP4 and MP3
- Difference between USB 2.0 and USB 3.0
- Difference between Tor and VPN
- Difference between TDM and FDM
- Difference between OOP and POP
- Difference between Blu-ray and DVD
- Difference between C and C++
- Difference Between SEO and SEM
- Difference between 1G and 2G
- Difference Between BFS and DFS
- Difference between C and C#
- Difference between URL and URI
- Difference between CRT and LCD
- Difference between WCF and Web API
- Difference between PNG and GIF
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.