Java中如何遍历map中的value值

是不是有方法
2025-12-16 13:43:51
推荐回答(1个)
回答1:

Map map = new HashMap();
Iterator it = map.keySet().iterator();
while(it.hasNext()){
int key = (Integer) it.next();
String value = map.get(key);
}

这个我写的一个例子。。。
没有直接遍历值的方法 只能先得到Map 中的key的集合
然后遍历出value