我是 Java 新手。
我有一张这样的 map 。
HashMap<String,HashMap<String,String>>mp;
如何遍历这个?
mp 里面还有另一个。
我知道使用entrySet遍历 map 的正常方式;
最佳答案
使用entrySet 遍历外部映射,然后对于外部映射的每个值,使用entrySet 遍历内部映射。
for (Map.Entry<String,HashMap<String,String>> entry : mp.entrySet()) {
for (Map.Entry<String,String> innerEntry : entry.getValue().entrySet()) {
...
}
}
关于java - java中如何遍历map内部的map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30437135/