AbstractMap.SimpleEntry<K, V> is used to maintain a key and a value entry. The value can be changed using the setValue method. This class facilitates the process of building custom map implementations.
setValue(V value) method of AbstractMap.SimpleEntry<K, V> used to replace the current value of map with the specified value passed as parameter.
public V setValue(V value)
Parameters: This method accepts the value we want to set.
Return value: This method return the old value corresponding to the entry.
Below programs illustrate setValue(V value) method:
Value changed from 123 to 2122425
Value changed from Dhoni to Kohli
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.