ArrayList源码学习分析
2019-01-07 本文已影响3人
雨夏_
1.ArrayList简介
1.ArrayList继承AbstractList,并且实现了List接口。其实现方式底层就是一个数组,并且实现了增加、删除、修改、遍历等方法。
2.ArrayList相对于Vector来说,效率比Vector更高,但是线程不安全。
2.ArrayList的属性

3.ArrayList的构造方法
ArrayList有三种构造方法:
1.无参构造

2.初始化List的容量

3.用一个Collection初始化List

4.ArrayList的添加方法
1.添加元素

2.指定位置插入元素

3.确认内部容量是否足够

4.扩容

5.ArrayList的删除方法
1.根据index删除指定元素

2.根据传入的元素,进行遍历删除

6.ArrayList的修改方法
1.根据index修改

7.ArrayList的查找方法
1.根据index查找

2.根据元素查找位置
