Association Aggregation and Composition in Java

By | June 17, 2022

In this post. We will talk and learn about Association Aggregation and Composition in Java


Association is the relation between two separate classes or entities that establish through their Objects. We can categorize associations in the following types:

  • one-to-one
  • one-to-many
  • many-to-one
  • many-to-many.

In the Object-Oriented programming world, an Object can communicate with other Objects by using functionalities and services provided by that object. Here key point is that Composition and Aggregation are mailny the two forms of association.


We can think that aggregation is a form of Association where:

  • It represents a has-A relationship.
  • It is a unidirectional association i.e. a one-way relationship. For example, a department can have employees but vice versa is not possible and thus unidirectional in nature.
  • In Aggregation, both the entries or classes can survive individually which means ending one entity will not affect the other entity


It is a restricted form of Aggregation in that two entities are highly dependent on each other.

  • It represents part-of relationship.
  • In composition, both entities are tightly coupled so each entity dependent on the other.
  • In the case of composition between two entities, the composed object cannot exist without the other entity.

You May Also Like:

Encapsulation in Java
Abstraction in Java
Understating of Polymorphism in Java
Method Overloading or Static Polymorphism in Java
Method Overriding or Dynamic Polymorphism in Java
Understating of Inheritance in Java

That’s all about Association Aggregation and Composition in Java

Leave a Reply

Your email address will not be published.