首页 > 其他 > 详细

Map遍历

时间:2020-01-01 17:08:12      阅读:77      评论:0      收藏:0      [点我收藏+]

代码如下

       //map的入口集合
       for(Map.Entry<String, String> mEntry:map.entrySet()){
           String key=mEntry.getKey();
           String value =mEntry.getValue();
           System.out.println(key+": "+value);
       }
       //map的迭代器
       Iterator<Entry<String, String>> iterator = map.entrySet().iterator();
       while(iterator.hasNext()){
           Entry<String, String> next = iterator.next();   
           System.out.println(next.getKey()+": "+next.getValue());
       }
       //map的key集合
       for(String key:map.keySet()){
           System.out.println(key+": "+map.get(key));
       }
       

Map遍历

原文:https://www.cnblogs.com/cstdio1/p/12129089.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!