首页 > 代码库 > Map的四种遍历方式

Map的四种遍历方式

public static void main(String[] args) {
 
 
  Map<String, String> map = new HashMap<String, String>();
  map.put("1", "value1");
  map.put("2", "value2");
  map.put("3", "value3");
   
  //第一种:普遍使用,二次取值
  System.out.println("通过Map.keySet遍历key和value:");
  for (String key : map.keySet()) {
   System.out.println("key= "+ key + " and value=http://www.mamicode.com/ " + map.get(key));> 

当一个人找不到出路的时候,最好的办法就是将当前能做好的事情做到极致,做到无人能及。

Map的四种遍历方式