Set Interface

Collection of unique elements

Set Interface

Does not allow duplicates.

Code Examples

Unique elements

java
1
2Set<Integer> set = new HashSet<>();
3set.add(1);
4set.add(1);
5          

Use Cases

  • Uniqueness

Common Mistakes to Avoid

  • Expecting order