[JAVA] LIST형 Remove 하기
List 를 삭제 할 경우 아래와 같이 작성을 할 경우 오류가 발생합니다.for(int i = 0; i < list.size(); i++ ) { list.remove(i); } List 를 삭제 하고자 할 경우에는 아래와 같이 iterator을 활용하여 삭제 하도록 합니다.list.add(“A”); list.add(“B”); list.add(“C”); for(Iterator it = list.iterator() ; it.hasNext() ; ) { it.next(); it.remove(); }
2019.04.16