Set is a collection that does NOT allow duplicate elements.
Key guarantees:
β No duplicates
β No index-based access
β Order depends on implementation
If you add the same element twice β itβs stored once.
Because many real-world problems need uniqueness:
β Unique usernames
β Unique email IDs
β Unique tags
β Remove duplicates from a list
Set handles this automatically.
Collection
βββ Set
βββ HashSet
βββ LinkedHashSet
βββ TreeSet