aspose file tools*
The moose likes Beginning Java and the fly likes Regarding List, ArrayList and LinkedList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regarding List, ArrayList and LinkedList" Watch "Regarding List, ArrayList and LinkedList" New topic
Author

Regarding List, ArrayList and LinkedList

Rohit W. Tawde
Greenhorn

Joined: Mar 12, 2013
Posts: 25

Hi,

In the javadoc, it says the following,

For ArrayList,
Methods inherited from interface java.util.List
containsAll, equals, hashCode

and for LinkedList,
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList


Aint all the methods like add, clear etc inherited from List interface.

Why does it mention that it has inherited only these few methods from the interface?

Also containsAll method is inherited by both ArrayList and LinkedList?


As per my understanding, A concrete subclass has to implement all the methods of the Interface it implements.
So why does the javadoc state that it inherits only these few methods ???

Also the containsAll has no implementation in the ArrayList class.
And as Interfaces dont implement methods, so where is the implementation of that method ???

Please help. Im a bit confused.


Rohit Tawde (SCJP5)
Mahender Parkipandla
Greenhorn

Joined: Dec 28, 2009
Posts: 21
Hi,

When you check ArrayList documentation, it says what are all the methods are inherited from which classes / interfaces.
There might be some of AbstractClasses which implement interface methods and those AbstractClasses will again be inherited by Concrete SubClasses.

ArrayList will inherit some AbstractClasses and hence the said methods are not implemeted in ArrayList.
Where as in LinkedList inherits some other Classes which might not implement the List classes.

Only ground rule is thta, the methods available in Interface should be implemnted by it's Classes which inherits it, if not, it will become AbstractClass.
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
The Java docs are automatically generated, you should not get disturbed by this facet of the documentation.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Regarding List, ArrayList and LinkedList