java.util.List

Soobin Kim·2024년 4월 6일

Java

목록 보기
46/47

java.util.Collection 메서드

메서드설명매개변수예외반환 타입
add(E e)해당 컬렉션에 요소를 추가한다. (선택 작업)E e-boolean
addAll(Collection<? extends E> c)해당 컬렉션에 지정된 컬렉션의 모든 요소를 추가한다. (선택 작업)Collection<? extends E> c-boolean
clear()해당 컬렉션의 모든 요소를 제거한다. (선택 작업)--void
contains(Object o)해당 컬렉션에 지정된 요소가 있는지 확인한다.Object o-boolean
containsAll(Collection<?> c)해당 컬렉션에 지정된 컬렉션의 모든 요소가 있는지 확인한다.Collection<?> c-boolean
equals(Object o)해당 컬렉션과 지정된 객체를 비교하여 동일한지 확인한다.Object o-boolean
hashCode()해당 컬렉션의 해시 코드 값을 반환한다.--int
isEmpty()해당 컬렉션이 비어 있는지 확인한다.--boolean
iterator()해당 컬렉션의 요소를 순회하는 Iterator를 반환한다.--Iterator
remove(Object o)해당 컬렉션에서 지정된 요소를 하나 제거한다. (선택 작업)Object o-boolean
removeAll(Collection<?> c)해당 컬렉션에서 지정된 컬렉션에 포함된 모든 요소를 제거한다. (선택 작업)Collection<?> c-boolean
removeIf(Predicate<? super E> filter)해당 컬렉션에서 지정된 조건을 만족하는 모든 요소를 제거한다. (선택 작업)Predicate<? super E> filter-boolean
retainAll(Collection<?> c)해당 컬렉션에서 지정된 컬렉션에 포함된 요소만을 남겨둔다.Collection<?> c-boolean
size()해당 컬렉션에 포함된 요소의 개수를 반환한다.--int
spliterator()해당 컬렉션의 요소에 대한 Spliterator를 생성하여 반환한다.--Spliterator
toArray()해당 컬렉션의 모든 요소를 포함하는 배열을 반환한다.--Object[]
toArray(IntFunction<T[]> generator)해당 컬렉션의 모든 요소를 지정된 생성 함수를 사용하여 포함하는 배열을 반환한다.IntFunction<T[]> generator-T[] or Object[]
toArray(T[] a)해당 컬렉션의 모든 요소를 지정된 배열에 담아 반환한다.T[] a-T[]

java.lang.Iterator 메서드

메서드설명매개변수예외반환 타입버전
iterator해당 컬렉션의 요소에 대한 반복자(Iterator)를 반환한다.없음없음Iterator1.8
forEachIterable의 각 요소에 대해 지정된 작업을 수행한다.Consumer<? super T> actionNullPointerExceptionvoid1.8
spliteratorIterable에 의해 설명된 요소에 대한 Spliterator를 생성한다.없음없음Spliterator1.8

java.util.List 메서드

메서드설명매개변수예외반환타입
add(int index, E element)지정된 위치에 요소를 삽입한다.int index, E elementIndexOutOfBoundsExceptionvoid
get(int index)지정된 위치의 요소를 반환한다.int indexIndexOutOfBoundsExceptionE
set(int index, E element)지정된 위치에 있는 요소를 주어진 요소로 대체한다.int index, E elementIndexOutOfBoundsExceptionE
remove(int index)지정된 위치의 요소를 제거하고 그 요소를 반환한다.int indexIndexOutOfBoundsExceptionE
replaceAll(UnaryOperator<E> operator)이 리스트의 각 요소를 주어진 연산자를 적용하여 바꾼다.UnaryOperator<E> operatorvoidNullPointerException
sort(Comparator<? super E> c)이 리스트를 지정된 Comparator에 의해 정렬한다.Comparator<? super E> cvoid-
indexOf(Object o)지정된 요소가 리스트에서 처음으로 나타나는 위치의 인덱스를 반환한다.Object o-int
lastIndexOf(Object o)지정된 요소가 리스트에서 마지막으로 나타나는 위치의 인덱스를 반환한다.Object o-int
listIterator()리스트 요소들을 순차적으로 액세스할 수 있는 리스트 이터레이터를 반환한다.--ListIterator<E>
listIterator(int index)지정된 위치에서 시작하는 리스트 이터레이터를 반환한다.int indexIndexOutOfBoundsExceptionListIterator<E>
subList(int fromIndex, int toIndex)지정된 범위에 있는 부분 리스트를 반환한다.int fromIndex, int toIndexIndexOutOfBoundsException, IllegalArgumentExceptionList<E>
copyOf(Collection<? extends E> coll)주어진 Collection의 요소를 포함하는 변경할 수 없는 List를 반환한다.Collection<? extends E> collList<E>NullPointerException
of()요소가 없는 변경할 수 없는 리스트를 반환한다.없음List<E>-
of(E e1)하나의 요소를 포함하는 변경할 수 없는 리스트를 반환한다.E e1List<E>NullPointerException
of(E... elements)임의의 개수의 요소를 포함하는 변경할 수 없는 리스트를 반환한다.E... elementsList<E>NullPointerException, IllegalArgumentException
of(E e1, E e2)두 개의 요소를 포함하는 변경할 수 없는 리스트를 반환한다.E e1, E e2List<E>NullPointerException
of(E e1, E e2, E e3)세 개의 요소를 포함하는 변경할 수 없는 리스트를 반환한다.E e1, E e2, E e3List<E>NullPointerException
of(E e1, E e2, E e3, E e4)네 개의 요소를 포함하는 변경할 수 없는 리스트를 반환한다.E e1, E e2, E e3, E e4List<E>NullPointerException
of(E e1, E e2, E e3, E e4, E e5)다섯 개의 요소를 포함하는 변경할 수 없는 리스트를 반환한다.E e1, E e2, E e3, E e4, E e5List<E>NullPointerException
of(E e1, E e2, E e3, E e4, E e5, E e6)여섯 개의 요소를 포함하는 변경할 수 없는 리스트를 반환한다.E e1, E e2, E e3, E e4, E e5, E e6List<E>NullPointerException
of(E e1, E e2, E e3, E e4, E e5, E e6, E e7)일곱 개의 요소를 포함하는 변경할 수 없는 리스트를 반환한다.E e1, E e2, E e3, E e4, E e5, E e6, E e7List<E>NullPointerException
of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8)여덟 개의 요소를 포함하는 변경할 수 없는 리스트를 반환한다.E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8List<E>NullPointerException
of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9)아홉 개의 요소를 포함하는 변경할 수 없는 리스트를 반환한다.E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9List<E>NullPointerException
of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10)열 개의 요소를 포함하는 변경할 수 없는 리스트를 반환한다.E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10List<E>NullPointerException

0개의 댓글