When I was seeing the declaration of ArrayList
class ArrayList extends AbstractList
implements List, RandomAccess
ArrayList and AbstractList implement List for different purposes.
List establishes what is required for a class to be a list.ArrayList implements List as part of defining its own interface. This is essential to what ArrayList is.ArrayList extends AbstractList as part of its own implementation. This is entirely optional: one could have implemented ArrayList from scratch without inheriting AbstractList, and the class would work in the same way.AbstractList is intended as a base class for other implementations of List. Instead of establishing an interface, it follows an existing one. AbstractList's implementation of List is not required, everything would compile and run without it just the same. However, inheriting List lets Java compiler spot potential discrepancies between the interface methods and the methods of AbstractList, so it is a very good idea for AbstractList to implement List interface.