This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes Aggregation and Composition query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Aggregation and Composition query" Watch "Aggregation and Composition query" New topic
Author

Aggregation and Composition query

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Please help me understand this


Aggregation: Life times of the objects are not the same, one object can live even after the other object has been destroyed.
Composition: life time of objects got to be the same.

But i seem to get all these things in theory, but when it comes to coding am not able to translate these theories. To be particular i would want someone to help with me how these relationship can be coded


Waiting for your responses.


If you want something you never had do something which you had never done
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Somebody has told you nonsense. Aggregation and Composition have nothing to do with the lifetimes of the objects, but how closely they fit together.

Aggregation: Car----Driver.

A Car remains a car when it hasn't got a driver.

Composition: Car----Wheel.

A Car isn't a complete car if you take the wheels away.
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Theoretically fine.

Can you provide me any example on to java code.
How can a java program suit for this ? please provide me an example
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
It's not a case of coding, but of design.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Aggregation and Composition query