Results 1 to 3 of 3
- 02-28-2013, 07:41 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 3
- Rep Power
- 0
Why both ArrayList and AbstractList are implements List interface?
Hi All,
I don't know the reason why the ArrayList & AbstractList classes are implements List interface as the AbstractList classes itseft it implements List interface.
AbstractList<E> extends AbstractCollection<E> implements List<E> {
ArrayList<E> extends AbstractList<E>
implements List<E>, RandomAccess, Cloneable, java.io.Serializable{
- 02-28-2013, 02:43 PM #2
Senior Member
- Join Date
- Jan 2013
- Location
- United States
- Posts
- 639
- Rep Power
- 1
Re: Why both ArrayList and AbstractList are implements List interface?
Well, unless there is something subtle that I am unaware of, it looks like a redundant declaration to me. You could still assign an ArrayList object to a List reference even if the ArrayList did not explicitly declare that it implements List. Perhaps others may have a different perspective.
An afterthought could be that it is simply a way to emphasize that ArrayList implements List (which is very useful to know). So it is somewhat self documenting as opposed to syntactically necessary.
JimLast edited by jim829; 02-28-2013 at 03:25 PM. Reason: Upon further consideration...
The Java™ Tutorial
YAT -- Yet Another Typo
- 02-28-2013, 04:36 PM #3
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: Why both ArrayList and AbstractList are implements List interface?
As Jim said the reason can be for documentation especially for the generated Javadoc so that the ArrayList will be included as a class that implements the java.util.List interface. And the AbstractList was there to implements some general features shared by the java.util.List implementation to reduce the code duplications.
Website: Learn Java by Examples
Similar Threads
-
Interface Inheritance : create class that implements the interface
By Zulkifli_Rahman in forum New To JavaReplies: 1Last Post: 07-08-2012, 05:23 PM -
What about variables? implements Interface > extends
By Bigfatcat in forum New To JavaReplies: 8Last Post: 01-08-2012, 08:57 AM -
Extends a class that implements an interface
By monocole in forum New To JavaReplies: 2Last Post: 12-27-2011, 03:55 AM -
Interface and implements
By Bored2 in forum New To JavaReplies: 27Last Post: 11-10-2010, 01:08 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks