Collection:
boolean | add(E e) 确保此 collection 包含指定的元素(可选操作)。如果此 collection 不允许有重复元素,并且已经包含了指定的元素,则返回 false | |
boolean | addAll(Collection<? extends E> c) 将指定 collection 中的所有元素都添加到此 collection 中(可选操作)。 | |
void | clear() 移除此 collection 中的所有元素(可选操作)。 | |
boolean | contains(Object o) 如果此 collection 包含指定的元素,则返回 true。 | |
boolean | containsAll(Collection<?> c) 如果此 collection 包含指定 collection 中的所有元素,则返回 true。 | |
boolean | isEmpty() 如果此 collection 不包含元素,则返回 true。 | |
Iterator<E> | iterator() 返回在此 collection 的元素上进行迭代的迭代器。 | |
boolean | remove(Object o) 从此 collection 中移除指定元素的单个实例,如果存在的话(可选操作)。 | |
boolean | removeAll(Collection<?> c) 移除此 collection 中那些也包含在指定 collection 中的所有元素(可选操作)。 | |
boolean | retainAll(Collection<?> c) 仅保留此 collection 中那些也包含在指定 collection 的元素(可选操作)。如果此 collection 由于调用而发生更改,则返回true | |
int | size() 返回此 collection 中的元素数。 | |
Object[] | toArray() 返回包含此 collection 中所有元素的数组。即使 collection 受到数组的支持,此方法也必须分配一个新的数组 | |
| toArray(T[] a) 返回包含此 collection 中所有元素的数组;返回数组的运行时类型与指定数组的运行时类型相同。 |
Set:
All the same with Collection.
List:
void | add(int index,E element) 在列表的指定位置插入指定元素(可选操作)。 |
boolean | addAll(int index,Collection<? extends E> c) 将指定 collection 中的所有元素都插入到列表中的指定位置(可选操作)。 |
E | get(int index) 返回列表中指定位置的元素。 |
int | indexOf(Object o) 返回此列表中第一次出现的指定元素的索引;如果此列表不包含该元素,则返回 -1。 |
int | lastIndexOf(Object o) 返回此列表中最后出现的指定元素的索引;如果列表不包含此元素,则返回 -1。 |
ListIterator<E> | listIterator() 返回此列表元素的列表迭代器(按适当顺序)。 |
ListIterator<E> | listIterator(int index) 返回列表中元素的列表迭代器(按适当顺序),从列表的指定位置开始。 |
E | remove(int index) 移除列表中指定位置的元素(可选操作)。 |
boolean | remove(Object o) 从此列表中移除第一次出现的指定元素(如果存在)(可选操作)。 |
E | set(int index,E element) 用指定元素替换列表中指定位置的元素(可选操作)。 |
List<E> | subList(int fromIndex, int toIndex) 返回列表中指定的 fromIndex(包括 )和 toIndex(不包括)之间的部分视图。 |
Queue:
boolean | add(E e) 将指定的元素插入此队列(如果立即可行且不会违反容量限制),在成功时返回 true,如果当前没有可用的空间,则抛出 IllegalStateException。 |
E | element() 获取,但是不移除此队列的头。 |
boolean | offer(E e) 将指定的元素插入此队列(如果立即可行且不会违反容量限制),当使用有容量限制的队列时,此方法通常要优于 add(E) ,后者可能无法插入元素,而只是抛出一个异常。 |
E | peek() 获取但不移除此队列的头;如果此队列为空,则返回 null。 |
E | poll() 获取并移除此队列的头,如果此队列为空,则返回 null。 |
E | remove() 获取并移除此队列的头。 |
Dequeue:
堆栈方法 | 等效 Deque 方法 |
push(e) | addFirst(e) |
pop() | removeFirst() |
peek() | peekFirst() |