find in hashmap java code example
Example 1: find a value in hashmap
if(hashMap.containsKey(key)) {
Object o = hashMap.get(key);
}
Example 2: hashmap get value java
//Import Hashmap
import java.util.HashMap;
HashMap<String, String> dir = new HashMap<String, String>();
//Add key, values
dir.put("hi", "hello");
dir.put("wow", "amazing");
//print value for hi.
System.out.println(dir.get("hi");