How to iterate Hashmap with containing arraylist

Possible Duplicate:
How do I iterate over each Entry in a Map?

i have map like

HashMap<Integer, ArrayList<String>> map = = new HashMap<Integer, ArrayList<String>>();

i want iterate this type of map please give me example how to iterate this map


for (Map.Entry<String, ArrayList<String>> entry : map.entrySet()) {
    String key = entry.getKey();
    ArrayList<String> value = entry.getValue();
    for(String aString : value){
        System.out.println("key : " + key + " value : " + aString);
    }
}

你可以这样做:

for (Integer i : map.keySet())
   for (String s : map.get(i))
      System.out.println("key :" + i + " value: " + s);
链接地址: http://www.djcxy.com/p/23964.html

上一篇: 打印java映射Map <String,Object>

下一篇: 如何迭代含有数组列表的Hashmap