목록array (2)
passion and relax
ArrayList. add(Object elem) : 객체 매개변수(elem)를 목록에 추가. remove(int index) : index 매개변수로 지정한 위치에 있는 객체를 제거. remove(Object elem) : 주어진 객체가 ArrayList에 있으면 그 객체를 제거. contains(Object elem) : 객체 매개변수 elem에 매치되는 것이 있으면 true. isEmpty() : 목록에 아무 원소도 없으면 true. indexOf(Object elem) : 객체 매개변수(elem)의 인덱스 또는 -1을 리턴. if (index >= 0) {} 과 함께 자주 사용됨.. size() : 현재 목록에 들어있는 원소의 개수 리턴. get(int index) : 주어진 index 매배변수 ..
자바에서 Array를 Set으로 변경하는 방법들 ⓞ 변경하고자 하는 배열String[] arrayFruit = {"apple", "banana", "kiwi", "apple"}; ① 다이아몬드 연산자 이용Set setFruit = new HashSet(Arrays.asList(arrayFruit)); ② Set.copyOf()Set setFruit = Set.copyOf(Arrays.asList(arrayFruit)); ③ Collections.addAll()Set setFruit = new HashSet();Collections.addAll(setFruit, arrayFruit); ④ 구글 commons 이용import com.google.common.collect.Sets;Set setFru..