Guest User

Untitled

a guest
Apr 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Map mymap = new HashMap();
  2. mymap.put("1","one");
  3. mymap.put("1","not one");
  4. mymap.put("1","surely not one");
  5. //the following line is case 2 for duplicate
  6. //mymap.put("1","one");
  7. System.out.println(mymap.get("1"));
  8.  
  9. public V put(K key,
  10. V value)
  11.  
  12. Map<String, ArrayList<String>> hashMap=new HashMap<String,
  13.  
  14. while(it.hasNext()){
  15. String key=it.next().toString();
  16. tempList=hashMap.get(key);
  17. if(tempList!=null){
  18. for(String value: tempList){
  19. System.out.println("Key : "+key+ " ,
  20.  
  21. } } ..... private void addValues(String key, String value){
  22. ArrayList tempList=null;
  23.  
  24. if(hashMap.containsKey(key)){
  25.  
  26. tempList=hashMap.get(key);
  27.  
  28. if(tempList==null)
  29. tempList=new ArrayList();
  30.  
  31. tempList.add(value);
  32.  
  33. }else{
  34. tempList=new ArrayList();
  35. tempList.add(value);
  36. }
  37.  
  38. hashMap.put(key,tempList);
  39. } .....
Add Comment
Please, Sign In to add comment