![]() |
VOOZH | about |
A HashMap is a data structure that implements a map interface in Java. It stores key-value pairs. On the key object's hashcode, it uses a hashing function for computing an index-based element. And it is used to store and retrieve values. This allows very fast lookup, addition, and removal of key-value pairs, with average O(1) time complexity.
In this article, we will learn how to retrieve a specific value from a HashMap using its key in Java.
HasMap.get(object key_element)Below is the implementation of retrieving a specific value from a HashMap using its key:
30000
Note: The get() method returns the value or null if key is not found.