Contents Prev: Lists Next: Maps

What are sets?

Sets store a distinct collection of objects.

Implementations

There's HashSet and TreeSet.

Set<String> set = new HashSet<>();
set.add("foo");
set.add("bar");

This is the output:

foo
bar
Contents Prev: Lists Next: Maps