What does the following code do? Can the LinkedHashSet be replaced with a HashSet?
public class CollectionFunction {
public <E> List<E> function(List<E> list) {
return new ArrayList<E>(new LinkedHashSet<E>(list));
}
}
What does the following code do?
It seems like it is used to remove duplicates from a list without changing the order
Can the LinkedHashSet be replaced with a HashSet?
No, it will not keep the order guaranteed (#2)