Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

ChangeElementsOfHashMap

// Java program to change
// elements of HashMap
 
import java.io.*;
import java.util.*;
class ChangeElementsOfHashMap {
    public static void main(String args[])
    {
 
        // Initialization of a HashMap
        HashMap<Integer, String> hm
            = new HashMap<Integer, String>();
 
        // Change Value using put method
        hm.put(1, "Geeks");
        hm.put(2, "Geeks");
        hm.put(3, "Geeks");
 
        System.out.println("Initial Map " + hm);
 
        hm.put(2, "For");
 
        System.out.println("Updated Map " + hm);
    }
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #ChangeElementsOfHashMap
ADD COMMENT
Topic
Name
8+9 =