This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what is the code trying to say between inheritance and aggregation? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "what is the code trying to say between inheritance and aggregation?" Watch "what is the code trying to say between inheritance and aggregation?" New topic
Author

what is the code trying to say between inheritance and aggregation?

sura watthana
Ranch Hand

Joined: Sep 13, 2004
Posts: 77
Hi,
I'm trying to figure out what the code below trying to say about the different between inheritance and aggregation. could somebody tell me, please? Thank you.




(added [C0DE][/C0DE] tags )
[ September 14, 2004: Message edited by: Barry Gaunt ]
Fletcher Estes
Ranch Hand

Joined: Jul 01, 2004
Posts: 108
Aggregation means a collection of properties which defines a class. Your QueueByAggregation demonstrates this because it has a member variable (or property/attribute) which is the previously defined LinkedList. The nature of the QueueByAggregation is determined by what it is composed of, rather than what it is natively.

Inheritance means a class is a type of a superclass. In this case, your StackByInheritance is a type of LinkedList. It can do anything a LinkedList can do, and may be treated as a LinkedList by other classes. The StackByInheritance doesn't have a LinkedList, like the QueueByAggregation, it simply is one.

Hope this helps
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: what is the code trying to say between inheritance and aggregation?
 
Similar Threads
Linked List Sorting Problem
Linked List Sorting Problems
How the insertAtBack sets the next for head?
Reversing a doubly linked list
Saving to a txt file