首页 > 编程语言 > 详细

Java中迭代Map的方法

时间:2017-07-22 12:35:47      阅读:220      评论:0      收藏:0      [点我收藏+]
            Map<String, String> mapServlet = new HashMap<String, String>();
       System.out.println("迭代方法一"); for( Object key:mapServlet.keySet()){ System.out.println( key ); System.out.println(mapServlet.get(key)); } System.out.println("迭代方法二"); for( Object value: mapServlet.values()){ System.out.println(value); } System.out.println("迭代方法三"); for(Iterator iterator = mapServlet.entrySet().iterator();iterator.hasNext();){ Object keyObject = iterator.next(); System.out.println(keyObject); } System.out.println("迭代方法四"); for(Iterator iterator = mapServlet.entrySet().iterator();iterator.hasNext();){ Map.Entry entry = (Entry)iterator.next(); System.out.println(entry.getKey()); System.out.println(entry.getValue()); }

 

Java中迭代Map的方法

原文:http://www.cnblogs.com/MrZhang1/p/7220777.html

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