We can get value of the key using get method for HashMap in Java. Following is the example code to access value for the Key.
Example Code:
HashMap<Integer,String> map = new HashMap<>();
map.put(1,”Hi”); //Add the keys and values with put() method
String val = map.get(1); // fetch the value for key ‘1’
System.out.print(“Value is”+val); //out put – Value is Hi
Vijaya bhaskar Alladi Changed status to publish