集合中collection、List、LinkedList等特有的方法

【集合中collection、List、LinkedList等特有的方法】Collection:
1.添加:boolean add(Object o) 、
boolean addAll(Collection c)
2.删除:boolean remove(Object o) 、
boolean removeAll(Collection c)
3.判断:boolean contains(Object o)
boolean containsAll(Collection c)
boolean isEmpty()
boolean equals(Object o)
4.获取---迭代器
Iterator iterator() //获取集合中的对象
int size() //获取集合中对象的个数
5.集合变数组
Object[] toArray()
List特有的方法:
1.增:在某个位置增加
void add(int index, E element)
boolean addAll(int index, Collection c)
2.删:在某个位置删除
E remove(int index) E:代表的是一种数据类型
E remove(int index) E:代表的是一种数据类型
3.改: E set(int index, E element)
System.out.println(list.set(1, "haha")); //返回值是被替换的元素
4.查:ListIterator listIterator()返回此列表元素的列表迭代器(按适当顺序)
ListIterator listIterator(int index)
List subList(int fromIndex, int toIndex) 包含开头,不包含结尾
E get(int index) 取指定下标的元素
5.删除全部对象:list.clear();
LinkedList特有的方法:
jdk1.6之前:
/addFirst()//始终在首位添加
//addLast()//始终在末尾添加
//getFirst()
//getLast()
//removeFirst()
//removeLast()
jdk1.6之后:
//offerFirst()
//offerLast()
//peekFirst()
//peekLast()
//pollFirst()
//pollLast()

    推荐阅读