If a class contains another class or object of another class as its member then Has-A relation is created between their class and their objects.
Aggregation represents part and whole relation between classes. It is weaker relation as both entity can exist independently.
For eg Room has chairs,Room has tables.
Aggregation can be implemented by containing the object of a class as member of another class.
Lets take an example of Employee and Address classes to implement aggregation. Here Address class object is a data member in Employee class.
program of Address.java
program of Employee.java
program of AggregationTest.java