How to implement a Set Data Structure in Java?

Basically, a Set is just a Map that only holds keys. So you should inform yourself about mappingalgorithms. Note: the HashSet for example is actually just an adapter for the HashMap. the add-method of HashSet simply uses HashMap.put(value , SomeDummyValue).


Set internally implements a map.So each value in a set is just a key in map.So its uniqueness in maintained.

Here is the link.So that you get clear idea how set works internally. Also few stack Answers. First , Second