Last Updated: 28 May, 2022
Aggregation represents HAS-A relationship between classes in Java, It is a special kind of association. which means a class contains reference of another class.
For example:
Employee has an entity reference Address, so relationship is Employee HAS-A Address.
Class: Address.java
Class: Employee.java
Class: AggregationExample.java
Output
Emp ID: 75
Emp Name: John
Employee Address Details:
ID: 101
Address: MG Road
City: Bangalore
State: Karnataka
For maintaining code reusability.
That's all guys, hope this Java article is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com