시소당
List 인터페이스는 순서 붙일 수 있는 컬렉션이다. 이 인터페이스의 사용자는 List 내의 어디에 각 요소가 삽입될까를 정밀하게 제어 할 수 있다. 사용자는 정수값의 인덱스(List 내의 위치)에 의해 요소에 액세스(access) 하거나 List 내의 요소를 검색할 수가 있다. Set 과는 다르게, 보통 일반적으로 List는 중복하는 요소를 허가한다.
package java.util;
public interface List extends Collection {
// Query Operations
int size();
boolean isEmpty();
boolean contains(Object o);
Iterator iterator();
Object[] toArray();
Object[] toArray(Object a[]);
// Modification Operations
boolean add(Object o);
boolean remove(Object o);
// Bulk Modification Operations
boolean containsAll(Collection c);
boolean addAll(Collection c);
boolean addAll(int index, Collection c);
boolean removeAll(Collection c);
boolean retainAll(Collection c);
void clear();
// Comparison and hashing
boolean equals(Object o);
int hashCode();
// Positional Access Operations
Object get(int index);
Object set(int index, Object element);
void add(int index, Object element);
Object remove(int index);
// Search Operations
int indexOf(Object o);
int lastIndexOf(Object o);
// List Iterators
ListIterator listIterator();
ListIterator listIterator(int index);
// View
List subList(int fromIndex, int toIndex);
}
Collection 인터페이스에서 제공해주던 메소드들에 List 인터페이스의 특징인 특정 위치의 요소를 찾거나 특정 위치에 요소를 추가하는 등의 메소드들이 추가되었다. 메소드 이름이 워낙 일관되고 명확하게 잘 지어져 있기 때문에(필자가 자바를 좋아하는 이유 중 하나) 메소드 이름만으로도 대강 어떤 역할을 하는지 짐작할 수 있을 것이다. List 인터페이스에서 추가된 메소드들은 Bold 를 주어 표현해놨다.