Explain the difference between HashSet and Hashmap?

devquora
devquora

Posted On: Feb 22, 2018

 

Difference between HashSet and HashMap are given below:

HashSetHashMap
The set interface is implemented by the HashSet class.The map interface is implemented by the HashMap class.
Objects like elements or values are stored inside the HashSet. For example, if there is HashSet of string elements then it can portray a set of HashSet elements.Key and value pairs are stored in HashMap. In other words, the mapping of Key and value is maintained by HashMap.
Duplicate elements are not allowed in HashSet, i.e., no duplicate values can be stored in it.Duplicate Key is not allowed in HashMap, but duplicate values can be stored.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Java Interview Questions asked in Citibank

    Explain Multi-Threading in Java?

    It is a process in java through which multiple threads can be executed simultaneously. A thread can be explained as a lightweight sub-process, it is the smallest unit of processing. Both multiprocessi...