Why LinkedList and arraylist extends AbstractList in java?

后端 未结 4 1356
一个人的身影
一个人的身影 2021-02-13 18:41

Why LinkedList and ArrayList extends AbstractList in Java?

Abstract classes are used when we want to specify a common beh

4条回答
  •  长情又很酷
    2021-02-13 19:11

    Usage is noted at the top of the AbstractList source file

    "This class provides a skeletal implementation of the {@link List} interface to minimize the effort required to implement this interface backed by a "random access" data store (such as an array). For sequential access data (such as a linked list), {@link AbstractSequentialList} should be used in preference to this class."

    So essentially it provides some methods to build around and a framework that is more robust than the List interface.

提交回复
热议问题