![]() |
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. Syntax:HasMap.get(object key_element)
Program to Retrieve a Specific Value From a HashMap Using Key in JavaBelow is the implementation of retrieving a specific value from a HashMap using its key: Java
Output
30000 Explanation of the above Program:
|
Reffered: https://www.geeksforgeeks.org
Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |