ArrayList()
ArrayList(Collection c)
ArrayList(int initialCapacity)
boolean add(Object o)
void add(int index, Object element)
boolean addAll(Collection c)
boolean addAll(int index, Collection c)
boolean remove(Object o)
Object remove(int index)
boolean removeAll(Collection c)
void clear()
int indexOf(Object o)
int lastIndexOf(Object o)
boolean contains(Object o)
Object get(int index)
Object set(int index, Object element)
List subList(int fromindex, int toindex) // 배열의 원하는 부분 새롭게 리스트로 만듬
Object[] toArray() // ArrayList의 객체 배열을 반환
Object[] toArray(Object[] a)
boolean isEmpty() // 비어있는지 확인
void trimToSize() // 빈 공간 제거
void size() // 저장된 객체 갯수 반환
list.remove(2);
를 호출
System.aaraycopy(data, 3, data, 2,2); // data[3]에서 data[2]로 2개의 데이터를 복사하라는 의미
data[size-1] = null;
size--;
마지막 데이터를 삭제하는 경우 1의 과정(배열 복사)는 필요하지 않다!
for(int i =0;i <list.size();i++){
list.remove(i);
}
for(int i = list.size()-1;i>=0;i--){
list.remove(i);
}
☃참고❄
자바의 정석- ArrayList