Aggregation in Java
If a class in java has entity reference, that is called aggregation.Think of a situation where an employee has name, has ID and has an Address which contains information such as Address, City, State etc. which is contained in class Address.This means class Employee HAS-A address.
Example Code
The main reason for using aggregation in java is to enable code reuse.
Example Code
public class Employee { String name; int id; Address address; }Class Address
public class Address { String city; String state; int zip_code; String street_name; }Why Aggregation in java
The main reason for using aggregation in java is to enable code reuse.