To replace elements of the Map, one can use the following methods:
- V replace(K, V): It replaces the value with the provided one only if the provided key is present in the map; returns the previous (replaced) value if such a key is present or null if such a key is not in the map
- boolean replace(K, oldV, newV) : It replaces the current value (oldV) with a new one (newV) only if the provided key is present in the map and is currently associated with the provided value oldV; returns true if the value was replaced
- void replaceAll(BiFunction<? super K, ? super V, ? extends V> function): It allows you to replace the values using a provided function that takes two parameters—key and value—and returns a new value that will replace ...