Set interface Properties/Rules:
✓ Insertion order is not preserved
✓ Only one null value is allowed
✓ It is not indexed type
✓ It does not allow duplicate elements and allows only unique elements.
✓add() is used to add the elements to the set
✓ To retrieve the elements from the Set we use for each loop.
✓HashSet, LinkedHashSet and TreeSet classes implements Set interface.
NOTE:
✓ How set preserves uniqueness?
The set preserves the uniqueness by comparing the hashcode value of the given object with the hashcode values of existing objects in the set.
If the hashcode values are same then it is considered as duplicate.
Below are the classes which implements Set interface .Click on each links below for more details.
(i) HashSet
(ii) LinkedHashSet
(iii) TreeSet