Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Regarding List, ArrayList and LinkedList

 
Greenhorn
Posts: 25
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 1041
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java docs are automatically generated, you should not get disturbed by this facet of the documentation.
 
It was the best of times. It was the worst of times. It was a tiny ad.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic