您的位置首页生活快答

map怎么遍历

map怎么遍历

的有关信息介绍如下:

map怎么遍历

通过map.entrySet()转成Set 再遍历。上面的方法是加入list集合再遍历

Set> entries = map.entrySet();

for (Map.Entry entry:entries) {

System.out.println("entry.getKey()----"+entry.getKey()+"======entry.getValue()----"+entry.getValue());

}