![]() |
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. Syntax of put() method:TreeMap.put(key, value) Where,
Program to Update the Value for an Existing Key in a TreeMapThis 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: Java
Output
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} Explanation of the above Program:
|
Reffered: https://www.geeksforgeeks.org
Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |