Q:

Java Program to get a key and the values contained in this map

0

Program to get a key and the values contained in this 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.put(1, "C#");
  hashmap.put(2, "C++");
  hashmap.put(3, "Java");
  hashmap.put(4, "Python");
  hashmap.put(5, "Ruby");
  System.out.println("Elements in a hashmap: " +hashmap);  
      
  Set key = hashmap.keySet(); 
  System.out.println("Collection Values are: "+ hashmap.values());
  System.out.println("Key values are: " + key);  
 }
}

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