List of utility methods to do List Duplicate Remove
void | removeDuplicates(List remove Duplicates for (int i = 0; i < list.size(); i++) { int j = i + 1; while (j < list.size()) { if (list.get(i).equals(list.get(j))) { list.remove(j); } else { j++; |
void | removeDuplicates(List Sorts and removes duplicate elements from list . Collections.sort(list, comparator); int j = 1; for (int i = 1; i < list.size(); i++) { if (comparator.compare(list.get(j - 1), list.get(i)) != 0) { T object = list.get(i); list.set(j++, object); if (j < list.size()) { list.subList(j, list.size()).clear(); |