In Java, there are several collections we can use for a variety of tasks – normally when we want a unique list, we should use a Set or a Set subclass. However, there are times when we want to unique-ify a different type of Collection (like an ArrayList). A simple way to do that is to create a HashSet (or a LinkedHashSet if you want to preserver the order of indexes), then pass the original Collection to the HashSet’s addAll method, clear the original Collection, then pass the HashSet to the original Collection’s addAll method… E.g.,