请教各位大侠,怎么样来遍历一个Map呢,最后用程序指点
    谢谢!!

解决方案 »

  1.   

    JDK 1.5 中遍历使用泛型参数的 Map Map<String, String> map = new HashMap<String, String>();for(Map.Entry<String, String> entry : map.entrySet()) {
      System.out.println(entry.getKey() + " --> " + entry.getValue());
    }
      

  2.   

    唉这个搂住好抠门啊,都不给分
    鉴于你给的报酬,我给出的答案是:使用Iterator,hoho :)
      

  3.   

    获取keySet(),然后遍历keySet不就可以了吗
      

  4.   

    Set set = map.keySet();
    Iterator it = set.iterator();
        for(;it.hasNext();) {
             System.out.println(map.get(it.next()));
    }
      

  5.   

    public class MyMap{
       public static void main(String[] args){
           Map map = new HashMap();
           map.put("1","2");
           map.put("2","3");
           Set set = map.entrySet();
           Iterator i = set.Iterator();
           while(i.hasNext){
              System.out.println(i.next);
           }
       }
    }
    一楼的可以..我这种方法也行