| Author |
ArrayList implements List Interface
|
SelvarajC Chennappan
Greenhorn
Joined: Aug 20, 2009
Posts: 6
|
|
Hi All,
AbstractList implements List and ArrayList extends AbstractList implements List.
doubt :Why ArrayList is implementing List again?
Regards,
Selvaraj C
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12921
|
|
Because ArrayList extends AbstractList (which implements List), ArrayList also automatically implements List.
If you look at the source code of ArrayList (in the file src.zip inside your JDK installation directory) you'll see that it explicitly implements interface List. It's not necessary to specify this, because it already implements List via its base class. Probably the people who wrote the ArrayList class just included this for clarity.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
SelvarajC Chennappan
Greenhorn
Joined: Aug 20, 2009
Posts: 6
|
|
Jesper Young wrote:Because ArrayList extends AbstractList (which implements List), ArrayList also automatically implements List.
If you look at the source code of ArrayList (in the file src.zip inside your JDK installation directory) you'll see that it explicitly implements interface List. It's not necessary to specify this, because it already implements List via its base class. Probably the people who wrote the ArrayList class just included this for clarity.
Thank you Jesper Young
Could you please explain the clarity, we are getting here?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
They are just saying again that ArrayList implements List so you won't need to go to AbstractList in the Javadoc pages to find out it implements List. You can see it from the ArrayList Javadoc page immediately.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: ArrayList implements List Interface
|
|
|