1.List
ArrayList
与LinkedList
区别
前者在随机访问元素方面有优势,后者可以通过较低的代价进行插入与删除。
2.Iterator
迭代器
Iterator<Pet> it = pets.inerator();
while(it.hasNext()) {
Pet pet = it.next()
}
迭代器只能单向移动,迭代器统一了对容器的访问
ListIterator
可以双向移动
3.Stack
栈(后进先出)LinkedList()提供支持
Stack<String> stack = new Stack<String>()
stack.push() ;//接受对象
stack.peek();//提供栈顶元素,不移除
stack.pop();//返回栈顶元素并移除
4.Set
不保存重复的元素
TreeSet
:保持元素处于排序状态,使用红黑树
HashSet
提供最快的查询速度,使用散列函数
LinkedHashSet
:以插入顺序保存元素
5.Map
hashMap
:快速访问
TreeMap
:保持Key始终处于排序状态
LinkHashMap
:保持元素插入的顺序,通过散列提供了快速访问的能力
6.Queue
队列(先进先出)LinkedList()提供支持
offer();//将一个元素插入到队尾,或者返回false
//不移除返回表头
peek();//队列为空时,返回null
element();//队列为空时,NoSuchElementException异常
//移除并返回表头
poll();//空,返回null
remove();//空,NoSuchElementException()异常