- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Fetch the value for a specific key in Java IdentityHashMap
To fetch the value for a specific key, use the get() method.
As a parameter, set the key you want to fetch and fetch the value.
Let’s say you need to fetch value of key 3
get("3")
The following is an example to fetch the value for a specific key in Java IdentityHashMap −
Example
import java.util.*; public class Demo { public static void main(String[] args) { Map<String, Integer> m = newIdentityHashMap<String, Integer>(); m.put("1", 100); m.put("2", 200); m.put("3", 300); m.put("4", 150); m.put("5", 110); m.put("6", 50); m.put("7", 90); m.put("8", 250); m.put("9", 350); m.put("10", 450); System.out.println("IdentityHashMap elements
"+ m); // Get the value of key 3 System.out.println("
The Value of key 3 in IdentityHashMap = " + m.get("3")); } }
Output
The output is as follows
IdentityHashMap elements {2=200, 4=150, 9=350, 7=90, 10=450, 6=50, 5=110, 8=250, 1=100, 3=300} The Value of key 3 in IdentityHashMap = 300
- Related Articles
- Check for the existence of a key in Java IdentityHashMap
- Check for the existence of a value in Java IdentityHashMap
- Fetch a specific column value (name) in MySQL
- Fetch the key from a KeyValue Tuple in Java
- JavaScript fetch a specific value with eval()?
- Check the HybridDictionary for a specific key in C#
- Query an array in MongoDB to fetch a specific value
- Fetch key-valuepair from Java LinkedHashSet
- Fetch the value from a LabelValue Tuple in Java
- Fetch the value in a Java Pair Class Tuple
- Create IdentityHashMap in Java
- Clone IdentityHashMap in Java
- IdentityHashMap class in Java
- MongoDB aggregation to fetch documents with specific field value?
- Fetch the value from Decade Tuple in Java

Advertisements