Difference Between Association
Difference Between Association
Composition
Association:----
// class bank
class Bank
{
private String name;
// bank name
Bank(String name)
{
this.name = name;
}
// employee class
class Employee
{
private String name;
// employee name
Employee(String name)
{
this.name = name;
}
System.out.println(emp.getEmployeeName() +
" is employee of " + bank.getBankName());
}
}
Run on IDE
Output:
Aggregation:------
The Aggregation is the week-association, if whenever the container object destroyed, They is
no guaranty destruction of contained objects ie, without existing the container object they
may be a changes of existing of contained objects ie, container object is just maintained the
references of the contained objects
Aggregation is a specialized form of association between two
or more objects in which the objects have their own life-cycle
but there exists an ownership as well. Aggregation is a typical
whole/part relationship but it may or may not denote physical
containment -- the objects may or may or be a part of the
whole. In aggregation the objects have their own life-cycle but
they do have ownership as well. As an example, an employee
may belong to multiple departments in the organization.
However, if the department is deleted, the employee object
wouldn't be destroyed. Note that objects participating in an
aggregation relationship cannot have cyclic aggregation
relationships, i.e., a whole can contain a part but the reverse is
not true. In the following code example, an aggregation
relationship is evident between the IDGBlogAuthor and
IDGBlogAccount classes.