java25(集合框架--02 list)
Collection:
|-- List:元素是有序的,元素可以重复。因为该集合体系有索引
|-- ArrayList:底层的数据结构使用的是数组结构特点:查询快,增删改慢,线程不同步
|-- LinkedList:底层的数据结构使用的是链表数据结构特点:查询慢,增删改快
|-- Vector:底层的数据结构使用的是数组结构特点:线程同步,被ArrayList替代了
|-- Set:元素是无序的,元素不可以重复
|-- HashSet:底层的数据结构使用的是哈希表
|-- TreeSet:底层的数据结构使用的是二叉树,可以对set集合中的元素排序
List基本方法:
凡是可以操作角标的方法都是该体系特有的方法
增:
add(index,element);
addAll(index,Collection);
删:
remove(index);
改:
set(index,element);
查:
get(index);
subList(from,to);
ListIterator:
如下图例子所示,使用迭代器取出元素的同时,又使用集合追加元素会造成安全问题

对于以上的线程安全问题,我们可以使用List集合特有的迭代器:ListIterator
ListIterator是Iterator的子接口。该接口只能通过List集合的listIterator方法获取

Vector中的枚举:
枚举就是Vector特有的取出方式。跟迭代器很像,但是因为其名称与方法名称过长,慢慢被迭代器取代了

LinkedList:

例:ArrayList存储对象:

例:对象去重:
