Retrieving Hashmap value by comparing hashmap key
Program:
Hashmap.java
[java]package com.ngdeveloper.com;
import java.util.HashMap;
import java.util.Map.Entry;
public class Hashmap {
public static void main(String[] args) {
String keyword="super";
HashMap<String, String> myMap = new HashMap<String, String>();
myMap.put("super", "java keyword");
myMap.put("array_merge", "php array function");
for (Entry<String, String> pair : myMap.entrySet()) {
if(pair.getKey().equalsIgnoreCase(keyword)){
System.out.println(keyword+" is: " + pair.getValue());
}
}
}
}[/java]
Output:
super is: java keyword
Thanks for reading this post…….!!!