File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Has-A relationsship explanation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Has-A relationsship explanation" Watch "Has-A relationsship explanation" New topic
Author

Has-A relationsship explanation

ranjan sarkar
Greenhorn

Joined: Jun 30, 2008
Posts: 7
Q)Man has a best friend who is a Dog
How you can explain this with Has-A relation
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 453



Man has a bestFriend. hence man will have a bestfriend variable.
......who is a Dog. hence bestFriend is an instance of class Dog.

avi sinha


SCJP 5.0 SCWCD 5.0
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
The Man-Dog example is called "association"; a Man does not cease to be a Man if the Dog dies.

The examples I have given are called "composition"; an Aeroplane without a Wing is no longer an aeroplane in the fullest sense of the word. And if you disagree, try taking the wings off your aeroplane at 29000 feet
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Has-A relationsship explanation