Work/java
ArrayList 중복 제거 및 순차 정렬 함수
승수
2013. 8. 20. 17:28
public List removeDuplicateWithOrder(ArrayList arlList) {
HashSet set = new HashSet();
List newList = new ArrayList();
for (Iterator iter = arlList.iterator(); iter.hasNext(); ) {
Object element = iter.next();
if (set.add(element)) newList.add(element);
}
arlList.clear();
arlList.addAll(newList);
return arlList;
}