updating in java hashmap code example Example: update value in hashmap java map.replace(key, map.get(key) + 1); //or map.put(key, map.get(key) + 1);