Substitute the values of entries within a map.
import public
|
The replace() method updates the value of an existing entry in the map. The entry can be identified either by its key or by both its key and value.
Choose one of the following:
public |
public |
K and V denote the data types of the keys and values within the map.
Parameter |
Description |
key |
Necessary: The key of the entry to be eliminated. |
old value |
Optional: The value associated with the entry to be removed. |
new value |
Necessary: The value to be written into the entry. |
Returns: |
If the oldValue argument is provided, it returns true if the entry was substituted and false otherwise. If the oldValue argument is omitted, it returns the value the entry had before replacement, or null if there’s no entry with the specified key. |