- HashSet is an implementation of Set Interface. HashMap is a implementation of Map interface
- HashSet stores Objects. HashMap stores data in <Key,Value> pair format.
- HashSet uses add method to add elements to HashSet, where as HashMap uses put method, which takes two arguments key, value.
- HashSet internally uses HashMap to store data.
- In case of the HashSet, adding the same object do nothing. In case of a HashMap, putting a new key,value pair with an existing key will overwrite the existing value to set a new value for that key.
- HashSet contains unique Keys. HashMap contains unique keys and allow duplicate values.
This blog is primarily focus on Java fundamentals and the libraries built on top of Java programming language. Most of the post are example oriented, hope you have fun in reading my blog....:)
Wednesday, 4 June 2014
Difference between hashSet and hashMap
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment