updating a key in map code example Example 1: change the value in a hashtable java map.replace(key, newValue); Example 2: java hashmap set value myMap.put(key, value);