1. 程式人生 > >JDK8原始碼閱讀筆記--------java.util.List

JDK8原始碼閱讀筆記--------java.util.List

List是一個有序集合,元素可以重複,是一個介面,繼承Collections介面

1.int size();

2.boolean isEmpty();

3.boolean contains(Object o);

4.Iterator<E> iterator();

Returns an iterator over the elements in this list in proper sequence

以適當的順序返回列表中元素的迭代器。

5.Object[] toArray();

6.boolean add(E e);

7.boolean remove(Object o);

8.boolean containsAll(Collection<?> c);

9.boolean addAll(Collection<? extends E> c);

10.boolean addAll(int index, Collection<? extends E> c);

11.boolean removeAll(Collection<?> c);

12.boolean retainAll(Collection<?> c);

只保留此列表中指定集合中包含的元素(可選操作)。換句話說,從該列表中刪除指定集合中不包含的所有元素。

13.void clear();

14.E get(int index);

15.E set(int index, E element);

16.void add(int index, E element);

17.E remove(int index);

18.int indexOf(Object o);

19.int lastIndexOf(Object o);

20.ListIterator<E> listIterator();