Java/JSP
[JAVA] ArrayList 데이터 중복 제거
개발로그
2013. 1. 2. 14:19
// ArrayList에 들어있는 데이터를 중복 제거하기
ArrayList<String> arrList = new
ArrayList<String>();
arrList.append("중복데이터");
arrList.append("중복데이터");
arrList.append("중복데이터");
arrList.append("중복데이터");
// HashSet 데이터 형태로 생성되면서 중복 제거됨
HashSet hs = new HashSet(arrList);
// ArrayList 형태로 다시 생성
ArrayList<String> newArrList = new ArrayList<String>(hs);