java Map操作搞了我半天

 

1.取map中的所有key

如:Set<String> keySet = map.keySet();//把map中的所有key放入set中,

然后遍历set:

   Iterator<String> it = keySet.iterator();

    while(it.hasNext()){

      String str =  it.hasNext();

      System.out(str);

    }

2.将map1赋值给map2的时候,不能用map2=map1;

要这样:map2.putAll(map);

posted @ 2015-03-06 16:42  Mr.YaoSch  阅读(161)  评论(0编辑  收藏  举报