Why use aggregation in Java?

Java Programming Java8Object Oriented Programming


When an object A contains a reference to another object B or we can say Object A has a HAS-A relationship with Object B, then it is termed as Aggregation.

Aggregation helps in reusing the code. Object B can have utility methods and which can be utilized by multiple objects. Whichever class has object B then it can utilize its methods.

Published on 22-Apr-2018 20:58:00