setting a new value to given key in map java code example Example: java hashmap set value myMap.put(key, value);