Monday, December 15, 2014
Aggregation in JAVA
If a class have an entity reference, it is known as Aggregation. Aggregation represents HAS-A relationship.
Consider a situation, Employee object contains many informations such as id, name, emailId etc. It contains one more object named address, which contains its own informations such as city, state, country, zipcode etc. as given below.
class Employee{
int id;
String name;
Address address;//Address is a class
...
}
In such case, Employee has an entity reference address, so relationship is Employee HAS-A address.
Why use Aggregation?
For Code Reusability.
Labels:
aggregation,
JAVA
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment