Ebay Interview Question
Software DevelopersCountry: United States
import java.util.HashMap;
public class ExampleOfHashMap {
public static void main(String[] args) {
HashMap<Integer,String> map = new HashMap<Integer, String>();
map.put(1, "sandip");
map.put(2, "soma");
map.put(3, "krishna");
map.put(4, "ajit");
System.out.println(map.keySet());
System.out.println(map.entrySet());
HashMap<Integer,String> map1 = new HashMap<Integer, String>();
map1.put(5, "anjali");
map1.put(6, "priyanka");
map.putAll(map1);
System.out.println(map1.entrySet());
System.out.println(map.entrySet());
}
}
public class ImplementHashMap{
- Anonymous July 06, 2015public static void main(String args[]){
HashMap<Integer,String> map = new HashMap<Integer,String>();
map.put(105,"Tom");
map.put(106,"Andrew");
map.put(108,"John");
map.put(110,"Maria Sent");
System.out.println("the elements in the map are : "+map);
System.out.println("the elements in the map are : "+map.entrySet());
}
}