how to change the value in hashmap java code example
Example 1: update value in hashmap java
map.replace(key, map.get(key) + 1);
//or
map.put(key, map.get(key) + 1);
Example 2: java hashmap set value
myMap.put(key, value);
map.replace(key, map.get(key) + 1);
//or
map.put(key, map.get(key) + 1);
myMap.put(key, value);