get key in hashmap java code example
Example 1: hashmap get value java
import java.util.HashMap;
HashMap<String, String> dir = new HashMap<String, String>();
dir.put("hi", "hello");
dir.put("wow", "amazing");
System.out.println(dir.get("hi");
Example 2: java hashmap get array of keys
for (int key : myHashMap.keySet()){
}
Example 3: java get keys from hashmap
hashmap.keySet()
Example 4: hashmap get value by key java
import java.util.HashMap;
HashMap<Int, String> examplehashmap=new HashMap<>();
{
examplehashmap.put(5, "example");
};
examplehashmap.get(5);