map遍历的几种方式分别是什么

  Iterator it=map.entrySet().iterator();

  System.out.println( map.entrySet().size());

  String key;

  String value;

  while(it.hasNext()){

  Map.Entry entry = (Map.Entry)it.next();

  key=entry.getKey().toString();

  value=entry.getValue().toString();

  System.out.println(key+"===="+value);

  }    for (Map.Entry entry : map.entrySet()) {

  System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());

  }登录后复制

您可能感兴趣的文章:

相关文章