Java List Remove Duplicate removeDuplicateWithOrder(List list)

Here you can find the source of removeDuplicateWithOrder(List list)

Description

remove Duplicate With Order

License

Open Source License

Declaration

public static void removeDuplicateWithOrder(List<String> list) 

Method Source Code


//package com.java2s;

import java.util.*;

public class Main {

    public static void removeDuplicateWithOrder(List<String> list) {
        Set<String> set = new HashSet<String>();
        List<String> newList = new ArrayList<String>();
        for (Iterator<String> iter = list.iterator(); iter.hasNext();) {
            String element = iter.next();
            if (set.add(element))
                newList.add(element);//w ww  . ja  va 2s .  c  o m
        }
        list.clear();
        list.addAll(newList);
    }
}

Related

  1. removeDuplicates(List l)
  2. removeDuplicates(List collection)
  3. removeDuplicates(List list)
  4. removeDuplicates(List list, Comparator comparator)
  5. removeDuplicates(List lst)
  6. removeDups(List in)
  7. removeEqualItems(List list)
  8. removeRepeat(List list)
  9. removeRepeat(List list)