A HashSet ensures all elements are unique, unlike a List.
A HashSet automatically prevents duplicate entries, making it ideal for collections where each element must be unique. For example, in an e-commerce catalog, if you want to store unique product IDs without duplicates, HashSet is preferred over a List.