Here you can find the source of removeDuplicateWithOrder(List arrayList)
public static void removeDuplicateWithOrder(List arrayList)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; public class Main { public static void removeDuplicateWithOrder(List arrayList) { Set set = new HashSet(); List newList = new ArrayList(); for (Iterator iter = arrayList.iterator(); iter.hasNext();) { Object element = iter.next(); if (set.add(element)) { newList.add(element);//w w w. j a v a 2 s . co m } } arrayList.clear(); arrayList.addAll(newList); } }