From charlesreid1


Sets are easy to implement in Java using hash tables - the value being stored in the hash table serves as its own key. If someone passes an object and says, "Does this object live in your Set?" you pass that object to the hash function, get your index back, go to the hash's big array, and you either get nothing back (in which case, the answer is no, sorry, it is not in our set) or you get an object back - the same object - with the same hash. And the fact that you find something means the answer is, yes, this object is in the set.

So a Set is just an object wrapping a hash table.

Set class in Java API docs:

AbstractSet class in Java API docs:

HashSet class in Java API docs:

TreeSet class in Java API docs: