Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collection

 
Nasir Khan
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Some of the concrete calsses in collection package imlement the interfaces which are also implemeted by their abstract super
classes.For example
LinkedList extends AbstractSequentialList extends AbstractList.
Both AbstractList and LinkedList implement List interface.Why both do that ?I mean if AbstractList implements List interface all functionality of the iterface will go to LinkedList ( sub-sub class of AbstractList) so why does LinkedList implemet the interface again??
Similar confusion for ArrayList and Vector both implement List interface and their super class AbstractList do the same.
[This message has been edited by Nasir Khan (edited December 15, 2000).]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Both AbstractList and LinkedList implement List interface.Why both do that ?I mean if AbstractList implements List interface all functionality of the iterface will go to LinkedList ( sub-sub class of AbstractList) so why does LinkedList implemet the interface again??"
I imagine it is written that way in the source code to make sure the Javadocs documentation generator picks up the link. As you say, it is not strictly necessary since implementing an interface is inherited.
Bill
 
Bharatesh H Kakamari
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adding to the Bill's message Vector has got synchronized methods. Hence the programmer need not provide for sychronization where as ArrayList doesn't provide. Due to this the performance with ArrayList is better (that is what the books say!) than that of Vector that is if the programmer does not require synchronization.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic