This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "" has a " relationship" Watch "" has a " relationship" New topic
Author

" has a " relationship

Hung Chang
Greenhorn

Joined: Oct 21, 2001
Posts: 16
can anyone explain to me what exactly is "has a" relationship..
thanx in advance
Michael Bruesch
Ranch Hand

Joined: Sep 23, 2001
Posts: 158
The "is a" relationship, as I assume you know, is inheritance, when one class extends another. Say you have a class "Plane" and another class "CommercialAirliner". A commercial airliner "is a" plane, therefore it would extend class Plane.
The "has a" relationship is what is called "aggregation". If you design a class called "Engine", and then design a class called "Car". A car "has a" engine. Therefore it would not extend engine, because a car is not an engine. It would therefore include an object of type Engine as one of its instance members.
Hope that's clear.
------------------
Michael J Bruesch
Codito, ergo sum...
I code, therefore I am.
My Java Games, I'm quite proud


Michael J Bruesch<br /><i>I code, therefore I am.</i>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: " has a " relationship
 
Similar Threads
Trying to access the instance variable of Class Bar from Class Foo --------- why error ?
WA #1.....word association
Webservices and .NET
Containment
Composition Vs Inheritance