遍历Map最有效率的方法

public static void main(String[] args)
{
   HashMap<String, String> hm = new HashMap<String, String>();
   hm.put("111", "222");
       
   Set<Map.Entry<String, String>> entrySet = hm.entrySet();
   Iterator<Map.Entry<String, String>> iter = entrySet.iterator();
   while (iter.hasNext())
   {
       Map.Entry<String, String> entry = iter.next();
       System.out.println(entry.getKey() + "" + entry.getValue());
   }
}

猜你喜欢

转载自www.cnblogs.com/heqing-blog/p/12144676.html