The implementation of java.util.ArrayList
implements List
as well as extends AbstractList
. But in java docs you can see that AbstractL
Then wouldn't it be redundant to implement List as well as extend AbstractList?
Yes, it is 100% redundant. However, Java implementors added interfaces very consistently in all public implementation of the collections library:
LinkedList
and ArrayList
extend AbstractList
which implements List
, and then implement List
themselves.HashSet
and TreeSet
extend AbstractSet
which implements Set
, and then implement Set
themselves.HashMap
and TreeMap
extend AbstractMap
which implements Map
, and then implement Map
themselves.My understanding is that they did so for documentation purposes: the authors wanted to show that ArrayList
is primarily a List
; the fact that ArrayList
extends AbstractList
is a less significant detail of its implementation. Same goes for the other public collection types.
Note that Arrays.ArrayList
class is not publicly visible, so its authors did not care to include List
explicitly.
As far as the failed conversion goes, this should come as no surprise, because the inner class Arrays.ArrayList
and the public class ArrayList
are unrelated to each other.