Here's my code:
public static void deleteDuplicates(ArrayList<String> list){
ArrayList<String> newList = new ArrayList<String>();
HashSet<String> set = new HashSet<String>();
for(int i = 0; i < list.size(); i++){
set.add(list.get(i));
}
newList.addAll(set);
return newList;
}
My input for this is the following:
1, 2, 2, 3, 4, 3, 1, 5, 5, 4, 1, 4, 5
And the output I'm getting is:
3, 2, 4, 1, 5
Can anyone explain why this is out of order?