@Test public void testRemoveDuplicate() throws Exception { List<String> items = new ArrayList<>(); items.add("3A"); items.add("3A"); CollectionUtils.removeDuplicateWithOrder(items); assertThat(items).hasSize(1); }
public static void removeDuplicateWithOrder(List list) { Set set = new HashSet(); List newList = new ArrayList(); for (Iterator iter = list.iterator(); iter.hasNext(); ) { Object element = iter.next(); if (set.add(element)) newList.add(element); } list.clear(); list.addAll(newList); }
CollectionUtils { public static void removeDuplicateWithOrder(List list) { Set set = new HashSet(); List newList = new ArrayList(); for (Iterator iter = list.iterator(); iter.hasNext(); ) { Object element = iter.next(); if (set.add(element)) newList.add(element); } list.clear(); list.addAll(newList); } }
CollectionUtils { public static void removeDuplicateWithOrder(List list) { Set set = new HashSet(); List newList = new ArrayList(); for (Iterator iter = list.iterator(); iter.hasNext(); ) { Object element = iter.next(); if (set.add(element)) newList.add(element); } list.clear(); list.addAll(newList); }  }
CollectionUtils { public static void removeDuplicateWithOrder(List list) { Set set = new HashSet(); List newList = new ArrayList(); for (Iterator iter = list.iterator(); iter.hasNext(); ) { Object element = iter.next(); if (set.add(element)) newList.add(element); } list.clear(); list.addAll(newList); }  static void removeDuplicateWithOrder(List list); }
CollectionUtils { public static void removeDuplicateWithOrder(List list) { Set set = new HashSet(); List newList = new ArrayList(); for (Iterator iter = list.iterator(); iter.hasNext(); ) { Object element = iter.next(); if (set.add(element)) newList.add(element); } list.clear(); list.addAll(newList); }  static void removeDuplicateWithOrder(List list);  }