
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Difference between Association and Aggregation in Java
Association
Association in terms of objects refers to "has a" relationship between two related objects. For example, a employee has a communication address.
class Employee { String name; Address communicationAddress; } class Address { String address; }
Aggregation
Aggregation in terms of objects refers to "has a"+ relationship between two related objects. For example, a department has multiple employees. It refers to having a collection of child objects in parent class. For example:
class Department { String name; List<Employee> employees; } class Employee { String name; }
Sr. No. | Key | Association | Aggregation |
---|---|---|---|
1 | Definition | Association refers to "has a" relationship between two classes which use each other. | Aggregation refers to "has a"+ relationship between two classes where one contains the collection of other class objects. |
2 | Flexibility | Inflexible in nature. | Flexible in nature. |
3 | Linkage | Linkage is needed to maintain association. | Linkage between objects in not mandatory. |
4 | UML | Lines are used to represent association. | Diamond shape next to assembly class is used to represent the aggregation relationship. |
- Related Articles
- Difference Between Aggregation and Association
- Association, Composition and Aggregation in Java\n
- Association, Composition and Aggregation in C#
- Difference Between Link and Association
- Difference between composition and aggregation
- Difference Between Aggregation and Composition
- Difference Between Platelet Agglutination and Aggregation
- What are the difference between Composition and Aggregation in C#?
- Aggregation in Java
- What is aggregation in Java?
- Why use aggregation in Java?
- Describe the symbiotic association between rhizobium and leguminous plants.
- Difference between Java and JavaScript.
- Difference between Go and Java.
- Difference Between C++ and Java

Advertisements