实现接口 |
Collection |
Collection |
Collection |
Collection |
Collection |
Collection |
列数 |
单列集合 |
单列集合 |
单列集合 |
单列集合 |
单列集合 |
单列集合 |
实现接口 |
List |
List |
List |
Set |
Set |
Set |
顺序重复 |
有顺序,可以重复 |
有顺序,可以重复 |
有顺序,可以重复 |
无顺序,不可重复 |
无顺序,不可重复 |
无顺序,不可重复 |
适用场景 |
访问查询遍历多,插入删除少 |
访问插入删除多,查询遍历少 |
|
|
访问查询遍历多,插入删除少 |
效率 |
高 |
|
低 |
相等判断 |
|
|
|
重写hashcode()、equal() |
重写hashcode()、equal() |
|
名字 |
列表 |
双向链式列表 |
已经不用了 |
数据单位 |
[data][to] |
[to][data][to] |
|
[data][to] |
[to][data][to] |
|
数据原理 |
[data1][to][data2][to] |
[to][data1][to][to][data2][to] |
|
[data1][to][data2][to] |
[to][data1][to][to][data2][to] |
|
null |
|
可以出现null |
|
可以出现null |
可以出现null |
|
初始化 |
ArrayList list = new arratList(); |
LinkedList list = new LinkedList(); |
Vector list = new Vector(); |
HashSet list = new HashSet(); |
LinkedHashSet list = new LinkedHashSet(); |
TreeSet list = new TreeSet(); |
查规则 |
E get(int index) |
同左 |
同左 |
同左 |
同左 |
同左 |
查 |
xx.get() |
同左 |
同左 |
同左 |
同左 |
同左 |
增规则 |
void add(int index, E element) |
同左 |
同左 |
同左 |
同左 |
同左 |
增 |
xx.add() |
同左 |
同左 |
同左 |
同左 |
同左 |
全增规则 |
boolean addAll(int index, Collection<? extends E> c) |
同左 |
同左 |
同左 |
同左 |
同左 |
全增 |
xx.addAll() |
同左 |
同左 |
同左 |
同左 |
同左 |
删规则 |
E remove(int index) |
同左 |
同左 |
同左 |
同左 |
同左 |
删 |
xx.remove() |
同左 |
同左 |
同左 |
同左 |
同左 |
全删规则 |
clear() |
同左 |
同左 |
同左 |
同左 |
同左 |
全删 |
xx.clear() |
同左 |
同左 |
同左 |
同左 |
同左 |
改规则 |
E set(int index, E element) |
同左 |
同左 |
同左 |
同左 |
同左 |
改 |
xx.set() |
同左 |
同左 |
同左 |
同左 |
同左 |
遍历while迭代器 |
Iterator iterator = list.iterator();while(iterator.hasNext()){System.out.println(iterator.next());} |
同左 |
同左 |
同左 |
同左 |
同左 |
遍历for迭代器 |
/ |
/ |
/ |
for (Iterator iterator1 = set.iterator();iterator1.hasNext(); ) {System.out.println(iterator1.next());} |
同左 |
同左 |
遍历for |
for(int i = 0;i < list.size();i++){System.out.println(list.get(i));} |
同左 |
同左 |
/ |
/ |
/ |
遍历增强for |
for(Object obj : list){System.out.println(obj);} |
同左 |
同左 |
同左 |
同左 |
同左 |
排序 |
|
|
|
|
|
自然排序、定制排序 |
扩容 |
线程 |
未实现同步,线程不安全 |
未实现同步,线程不安全 |
实现了同步,线程安全 |
未实现同步,线程不安全 |
Jdk7 |
Jdk8 |