Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Changing or Replacing Elements in java map

// Java program to demonstrate
// the working of Map interface

import java.util.*;
class Main {
	public static void main(String args[])
	{

		// Initialization of a Map
		// using Generics
		Map<Integer, String> hashmap1= new HashMap<Integer, String>();

		// Inserting the Elements
		hashmap1.put(1, "Apple");
		hashmap1.put(2, "Banana");
		hashmap1.put(3, "Mango");

		System.out.println("Initial Map " + hashmap1+"
");

		hashmap1.put(new Integer(2), "Orange");

		System.out.println("Updated Map " + hashmap1);
	}
}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Changing #Replacing #Elements #java #map
ADD COMMENT
Topic
Name
8+7 =