Development/Java

List Conllection의 중복제거를 위한 HashSet Collection

망할고양이 2018. 4. 6. 11:56
1
2
3
4
5
6
7
8
 
 
// HashSet과 LinkedHashSet의 차이는 중복이 제거 될 때 HashSet은 기존 리스트의 구성요서의 순서가 지켜지지 않는다 
 
List<String> uniqueItems = new ArrayList<String>(new HashSet<String>(returnitems));
 
 
List<String> uniqueItems = new ArrayList<String>(new LinkedHashSet<String>(returnitems));
cs