Advertisement
apl-mhd

Map in Arraylist

Apr 22nd, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.*;
  4.  
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) {
  9. // write your code here
  10.  
  11.  
  12. ArrayList<HashMap<Integer,Integer>> ob[] = new ArrayList[10];
  13.  
  14. ob[0] = new ArrayList<HashMap<Integer, Integer>>();
  15.  
  16. HashMap<Integer, Integer> mp = new HashMap<Integer, Integer>();
  17.  
  18. mp.put(10,20);
  19.  
  20. ob[0].add(mp);
  21.  
  22. //int a = ob[0].get(0).get(10);
  23.  
  24. HashMap A = ob[0].get(0);
  25.  
  26.  
  27. Map<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
  28.  
  29. map.put("a",new ArrayList<String>());
  30.  
  31. map.get("a").add("10");
  32.  
  33. Iterator it = map.entrySet().iterator();
  34.  
  35. while (it.hasNext()) {
  36. Map.Entry pairs = (Map.Entry)it.next();
  37.  
  38.  
  39. System.out.println(pairs.getKey() + " = " + pairs.getValue());
  40.  
  41. String b = (String) pairs.getKey();
  42.  
  43. }
  44.  
  45.  
  46.  
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement