kri shan wrote:Whether HashSet uses hashing technique(equals and hashCode()) like HashMap/Hashtable for storing/retrieving elements?
From the source:
That single object is the value for each key.
Rob Prime wrote: The current HashSet implementation is little more than a wrapper around a HashMap key set..
This is also true for many alternative implementations, such as the ImmutableSet from the Google-Collections library. Most of the time, a HashSet is a HashMap, with the value either null or set to a constant dummy object.
Adds the specified element to this set if it is not already present.
Object o is the key or value?
So Paul C is correct to say it does not behave as a Map with key and value, but as a Set with elements only.
Which version of Java is that? For the last 5½ years, it has read add(E e) or similar.
kri shan wrote:add(Object o)