注册
登录
java
遍历HashMap
返回
遍历HashMap
作者:
狗头军师
发布时间:
2025-02-02 09:05:06 (2天前)
迭代中的项目的最佳方法是HashMap什么?
收藏
举报
2 条回复
1#
回复此人
v-star*위위
|
2020-07-28 15-59
entrySet()像这样遍历: ``` public static void printMap(Map mp) { Iterator it = mp.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry)it.next(); System.out.println(pair.getKey() + " = " + pair.getValue()); it.remove(); // avoids a ConcurrentModificationException } } ```
编辑
登录
后才能参与评论