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