Monday, July 21, 2008

Remove duplicates from a List


Set set = new HashSet();
set.addAll(list);

// avoid overhead :D
if(set.size() < list.size()) {
list.clear();
list.addAll(set);
}

No comments: