Q:

Java Program to copy all of the mappings from the specified map to another map

0

Program to copy all of the mappings from the specified map to another map

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.*;  
public class demo1 
{  
 public static void main(String args[]) 
 {  
  HashMap<Integer,String> hashmap= new HashMap<Integer,String>();
  HashMap <Integer,String> hashmap1 = new HashMap <Integer,String> ();
  hashmap.put(1, "C#");
  hashmap.put(2, "C++");
  hashmap.put(3, "Java");
  System.out.println("\nValues in first map: " + hashmap);
  
  hashmap1.put(4, "Python");
  hashmap1.put(5, "Ruby");
  System.out.println("\nValues in second map: " + hashmap1);

  hashmap1.putAll(hashmap);
  System.out.println("\nValues in a map are: " + hashmap1);
 }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now