I am a beginner in Java, so this may be a dumb question. Why we need hashSet in Java? I just learned that Java hashSet is actually implemented with HashMap. In my understanding, whenever we use hashSet, we can always use hashmap, so why we need hashSet in java?
Thanks
Setand notMap?This class implements the Set interface, backed by a hash table (actually a HashMap instance).. In fact I always think it is a common sense to know HashSet is internally using a HashMap, while TreeSet using a TreeMap