HashMap is a implementation of Map interface

HashSet is an implementation of Set Interface
HashMap Stores data in form of key value pair

HashSet Store only objects
Put method is used to add element in map

Add method is used to add element is Set
In hash map hashcode value is calculated using key object

Here member object is used for calculating hashcode value which can be same for two objects so equal () method is used to check for equality if it returns false that means two objects are different.
HashMap is faster than hashset because unique key is used to access object

HashSet is slower than Hashmap

Advertisements