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