内容介绍

在java中遍历Map对象的方法。

Map对象

Map<String,Object> map = new HashMap<>();
map.put("xiaoming", 1.78);
map.put("wanghong", 1.64);
map.put("zhangcan", 1.58);

遍历

for (Map.Entry<String, Object> entity : map.entrySet()){
    System.out.println(String.format("key[%s]---->[%s]", entity.getKey(),entity.getValue()));
}

结果

java 如何遍历Map对象

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2021-12-31
猜你喜欢
  • 2021-12-18
  • 2022-12-23
  • 2021-07-20
  • 2021-06-21
  • 2021-07-07
  • 2022-12-23
  • 2021-11-30
相关资源
相似解决方案