java 通过Iterator输出Map

 1 package test;
2
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.HashMap;
6 import java.util.Iterator;
7 import java.util.List;
8 import java.util.ListIterator;
9 import java.util.Map;
10 import java.util.Set;
11 import java.util.SortedSet;
12 import java.util.TreeSet;
13
14
15 public class test {
16 public static void main(String[] args) {
17 Map<String,String> map=new HashMap<String,String>();
18 map.put("Zhukai","is_a_2HUO!");
19 map.put("LiJunDong","is_a_2HUO_too!");
20 map.put("WoZiji","is_not_2HUO!");
21 Set<Map.Entry<String, String>> allSet=map.entrySet();
22
23 Iterator<Map.Entry<String, String>> iter=allSet.iterator();
24 while(iter.hasNext()){
25 Map.Entry<String, String> me=iter.next();
26 System.out.println(me.getKey()+ " "+me.getValue());
27 }
28
29 }
30 }

 

posted @ 2012-03-30 21:35  谈笑风生膜法师  阅读(10946)  评论(1编辑  收藏  举报