---
title: "Aggregation and Composition in java"  
description: "Aggregation and Composition in java"  
author: "Royce Roy"  
published: 2015-03-17  
updated: 2015-03-17  
canonical: https://www.mindstick.com/forum/23021/aggregation-and-composition-in-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# Aggregation and Composition in java

can any one [explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) the **[aggregation](https://www.mindstick.com/forum/217/what-is-aggregation-and-how-it-maps-into-a-java-class)** and **[composition](https://yourviews.mindstick.com/audio/1187/gre-graduate-record-examination-its-pattern-composition)** with the low level example that i can understand easily example should be [programming](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming) example\

## Replies

### Reply by Anonymous User

For car example:\
**Composition:** Car and wheel. **Aggregation:** Car and passenger.\
\
This diagram will make the difference more clear among the relationships:\
![Aggregation and Composition in java](https://www.mindstick.com/mindstickforums/64105f2f-0c42-4733-8b81-e16553424544/images/2bbc2bcd-02f4-4ff6-b212-240f18f8cafb.png)\

### Reply by Samuel Fernandes

**Composition** means that the object doesn't make sense without the composed part.**Aggregation** means the aggregated part can exist independently from the object. \
**Example:** a car doesn't make much sense without an axle and vice versa. So a car is composed of an axle. But the CD player in the car can exists independently from the car (in some cases). So the car and the CD player are aggregated.


---

Original Source: https://www.mindstick.com/forum/23021/aggregation-and-composition-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
