Here you can find the source of removeDuplicateWithOrder(List
public static void removeDuplicateWithOrder(List<String> list)
//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); } }