What does the following code do?
It seems to be used to remove duplicates from a list without changing the order
- deletes duplicates (LinkedHashSet is a collection)
- supports insertion order ( LinkedHashSet has a predictable iteration order)
- convert back to list
Can I replace LinkedHashSet with a HashSet?
No, it will not keep the guaranteed order (# 2)
source
share