![]() |
VOOZH | about |
TreeMap is a part of Java Collection that can in-built class of java.util package. In Java, TreeMap is a pre-defined class that implements the NavigableMap interface and extends the AbstractMap class.
In this article, we will be learning how to update the value for an existing key in a TreeMap using the basic put() method in Java.
TreeMap.put(key, value)
Where,
This method is very simple, and it allows to insertion of a new value for an existing key by using the put() method.
Below is the Program to Update the Value for an Existing Key in a TreeMap Using put() in Java:
Oringinal TreeMap:{1=GeeksForGeeks, 2=DSA Tutorial, 3=Java Tutorial, 4=Python Tutorial}
Updated TreeMap:{1=GeeksForGeeks, 2=Full Stack Web Development, 3=Java Tutorial, 4=Python Tutorial}