ArrayList 클래스는 본 그림에서와 같이 List를 구현한다.

반환타입이 boolean인 메서드들은 작업에 성공하거나 사실이면 true, 아니면 false를 반환한다.
| 메서드 | 기능 |
|---|---|
| ArrayList() | 크기가 10인 ArrayList를 생성 |
| ArrayList(Collection c) | 주어진 컬렉션이 저장된 ArrayList를 생성 |
| ArrayList(int initialCapacity) | 지정된 초기용량(initialCapacity)를 갖는 ArrayList 생성 |
| 메서드 | 기능 |
|---|---|
| boolean add(Object o) boolean addAll(Collection c) | 지정된 객체(o) 또는 Collection(c)의 객체들을 ArrayList에 추가. |
| void add(int index, Object element) boolean addAll(int index, Collection c) | 지정된 위치(index)에 객체(element) 또는 컬렉션(c)에 포함된 객체들을 추가 |
| 메서드 | 기능 |
|---|---|
| boolean contains(Object o) boolean containsAll(Collection c) | 지정된 객체(o) 또는 Collection(c)의 객체들이 포함되어 있는지 확인. |
| int indexOf(Object o) | 지정된 객체의 위치(index)를 반환 (List의 첫 번째 요소부터 순방향으로 탐색) |
| int lastIndexOf(Object o) | 지정된 객체의 위치(index)를 반환 (List의 마지막 요소부터 역방향으로 탐색) |
| 메서드 | 기능 |
|---|---|
| boolean remove(Object o) boolean removeAll(Collection c) | 지정된 객체(o) 또는 Collection(c)의 객체들을 삭제. |
| Object remove(int index) | 지정된 위치(index)에 있는 객체를 삭제하고 삭제한 객체를 반환 |
| boolean retainAll(Collection c) | 지정된 Collection에 포함된 객체만을 남기고, 다른 객체들은 ArrayList에서 삭제 집합의 교집합 개념과 유사함. |
| void clear() | ArrayList의 모든 객체를 삭제 |
| 메서드 | 기능 |
|---|---|
| Object get(int index) | 지정된 위치(index)에 있는 객체를 반환 |
| Object set(int dex, Object element) | 지정된 위치(index)에 있는 객체를 element로 변경 |
| 메서드 | 기능 |
|---|---|
| Object clone() | ArrayList를 복제 |
| boolean equals(Object o) | 동일한 ArrayList인지 확인 |
| int hashCode() | ArrayList의 해시 코드를 반환 |
| 메서드 | 기능 |
|---|---|
| Iterator iterator() | 해당 ArrayList의 iterator를 얻어서 반환 |
| ListIterator listIterator() ListIterator listIterator(int index) | 해당 ArrayList의 객체에 접근할 수 있는 ListIterator를 얻어서 반환 |
| 메서드 | 기능 |
|---|---|
| void ensureCapacity(int minCapacity) | ArrayList의 용량이 최소한 minCapacity가 되도록 변경 |
| boolean isEmpty() | ArrayList가 비어있는지 확인 |
| int size() | ArrayList에 저장된 객체의 개수를 반환 |
| void sort(Comparator c) | 지정된 비교자(comparator)로 ArrayList를 정렬 |
| void trimToSize() | 용량을 크기에 맞게 변경 (빈공간을 삭제) |
| 메서드 | 기능 |
|---|---|
| Object[] toArray() | ArrayList에 저장된 객체를 객체배열(Object[])로 반환 |
| Object[] toArray(Object[] a) | 지정된 배열에 ArrayList의 객체를 저장해서 반환 |
| List subList(int fromIndex, int toIndex) | 지정된 범위(fromIndex부터 toIndex)에 있는 객체를 반환 |
자바의 정석 3판 (저자 : 남궁성)
Java Collections Framework Video Tutorial
오라클 Java 문서