ArrayList 클래스의 생성자, ArrayList 클래스의 주요메소드

CODEDRAGON Development/Java

반응형



 

ArrayList 클래스의 생성자

Method

Description

ArrayList()

·       크기가 0 ArrayList 생성합니다.

ArrayList(Collection c)

·       주어진 컬렉션이 저장된 ArrayList 생성합니다.

ArrayList(int initialCapacity)

·       지정된 초기용량을 갖는 ArrayList 생성합니다.

ArrayList(int initialCapacity, int capacityIncrement)

·       지정된 초기 용량과 용량의 증분을 갖는 ArrayList 생성합니다.

 

 

 

 

ArrayList 클래스의 주요메소드

Method

Description

boolean add(Object o)

·       ArrayList 마지막에 객체를 추가합니다.

·       Adds the object parameter t the list.

 

·       성공하면 true, 그렇지않으면 false 반환합니다.

void add(int index, Object element)

·       지정된 위치(index) 객체를 저장합니다.

boolean addAll(Collection c)

·       주어진 컬렉션의 모든 객체를 저장합니다.

boolean addAll(int index, Collection c)

·       지정된 위치부터 주어진 컬렉션의 모든 객체를 저장합니다.

void clear()

·       ArrayList 완전히 비웁니다.

Object clone()

·       ArrayList 복제합니다.

boolean contains(Object o)

·       지정된 객체가 ArrayList 포함되어 있는지 확인합니다.

·       Returns 'true' if there's a match for the object parameter.

void ensureCapacity(int minCapacity)

·       ArrayList 용량이 최소한 minCapacity 되도록 합니다.

Object get(int index)

·       지정된 위치에 저장된 객체를 반환합니다.

·       Returns the object currently at the index parameter.

int indexOf(Object o)

·       지정된 객체가 저장된 위치를 찾아 반환합니다.

·       Returns either the index of the object parameter, or -1.

boolean isEmpty()

·       ArrayList 비어있는지 확인합니다.

·       Returns 'true' if the list has no elements.

Iterator iterator()

·       ArrayList Iterator객체를 반환합니다.

int lastIndexOf(Object o)

·       객체(o) 저장된 위치를 끝부터 역방향으로 검색해서 반환합니다.

ListIterator listIterator()

·       ArrayList ListIterator 반환합니다.

ListIterator listIterator(int index)

·       ArrayList 지정된 위치부터 시작하는 ListIterator 반환합니다.

Object remove(int index)

·       지정된 위치에 있는 객체를 제거합니다.

·       Removes the object at the index parameter.

boolean remove(Object o)

·       지정한 객체를 제거합니다.

·       Removes this object(if it's in the ArrayList).

 

·       성공하면 true, 그렇지않으면 false 반환합니다.

boolean removeAll(Collection c)

·       지정한 컬렉션에 저장된 것과 동일한 객체들을 ArrayList에서 제거합니다.

boolean retainAll(Collection c)

·       ArrayList 저장된 객체 중에서 주어진 컬렉션과 공통된 것들만을 남기고 나머지는 삭제합니다.

Object set(int index, Object element)

·       주어진 객체(element) 지정된 위치(index) 저장합니다.

int size()

·       ArrayList 저장된 객체의 개수를 반환합니다.

·       Returns the number of elements currently in the list.

void sort(Comparator c)

·       지정된 정렬기준(c)으로 ArrayList 정렬합니다.

List subList(int fromIndex, int toIndex)

·       fromIndex부터 toIndex사이에 저장된 객체를 반환합니다.

Object[] toArray()

·       ArrayList 저장된 모든 객체들을 객체배열로 반환합니다.

Object[] toArray(Object[] a)

·       ArrayList 저장된 모든 객체들을 객체배열 a 담아 반환합니다.

void trimToSize()

·       용량을 크기에 맞게 줄입니다. 공간은 제거합니다.

 

 


반응형