List接口概述
有序的 collection(也称为序列)
此接口的用户可以对列表中每个元素的插入位置进行精确地控制。用户可以根据元素的整数索引(在列表中的位置)访问元素,并搜索列表中的元素
与 set 不同,列表通常允许重复的元素
List接口成员方法
void add(int index,E element)
E remove(int index)
E get(int index)
E set(int index,E element)
ListIterator listIterator()
ListIterator接口的成员方法
boolean hasPrevious()
E previous()
ConcurrentModificationException
现象
原因
解决方案
常见的数据结构
栈
队列
数组
链表
树
哈希表
ArrayList类概述及使用
ArrayList类概述
底层数据结构是数组,查询快,增删慢
线程不安全,效率高
ArrayList案例
存储字符串并遍历
存储自定义对象并遍历
Vector类概述及使用
Vector类概述
底层数据结构是数组,查询快,增删慢
线程安全,效率低
Vector类特有功能
public void addElement(E obj)
public E elementAt(int index)
public Enumeration elements()
LinkedList类概述及使用
LinkedList类概述
底层数据结构是链表,查询慢,增删快
线程不安全,效率高
LinkedList类特有功能
public void addFirst(E e)及addLast(E e)
public E getFirst()及getLast()
public E removeFirst()及public E removeLast()