I am performing some maintenance tasks on the old system. I have an arraylist that contains the following values:
a,b,12
c,d,3
b,a,12
d,e,3
a,b,12
I used the following code to remove duplicate values from arraylist
ArrayList<String> arList;
public static void removeDuplicate(ArrayList arlList)
{
HashSet h = new HashSet(arlList);
arlList.clear();
arlList.addAll(h);
}
It works great if it finds the same duplicate values. However, if you look carefully at my data, there are several duplicate entries, but not in the same order. For example, a, b, 12 and b, a, 12 are but in a different order.
How to remove this type of duplicate records from arraylist?
thank
source
share