
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Aggregation in Java
Aggregation refers to HAS-A relationship. Let’s look at the example first −
Example
public class Vehicle{} public class Speed{} public class Van extends Vehicle { private Speed sp; }
This shows that class Van HAS-A Speed. By having a separate class for Speed, we do not have to put the entire code that belongs to speed inside the Van class, which makes it possible to reuse the Speed class in multiple applications.
In the Object-Oriented feature, the users do not need to bother about which object is doing the real work. To achieve this, the Van class hides the implementation details from the users of the Van class. So, basically what happens is the users would ask the Van class to do a certain action and the Van class will either do the work by itself or ask another class to perform the action.
This concept of containing an object to do action is termed as Aggregation.
- Related Questions & Answers
- What is aggregation in Java?
- Why use aggregation in Java?
- Association, Composition and Aggregation in Java
- Difference between Association and Aggregation in Java
- What is aggregation in C#?
- Composition vs Aggregation in C#
- Perform aggregation sort in MongoDB?
- MongoDB divide aggregation operator?
- MongoDB aggregation and projection?
- What is Data Aggregation?
- Different Aggregation functions in SAP HANA
- Association, Composition and Aggregation in C#
- Aggregation in MongoDB for nested documents?
- Difference between composition and aggregation
- MongoDB aggregation with multiple keys