集合源码分析[2]-AbstractList 源码分析

AbstractList

  1. 类型:抽象类java

  2. 接口的继承以及实现关系dom

    1. 继承AbstractCollection
    2. 实现List接口

  1. 典型方法实现解析this

    1. public List<E> subList(int fromIndex, int toIndex)将集合从fromIndex到toIndex地方进行剪切
    public List<E> subList(int fromIndex, int toIndex) {
            return (this instanceof RandomAccess ?
                    new RandomAccessSubList<>(this, fromIndex, toIndex) :
                    new SubList<>(this, fromIndex, toIndex));
        }
    • 判断是否有随机访问的接口若是有则床架一个随机访问的List子集合,不然返回SubList
相关文章
相关标签/搜索