我想遍历一个嵌套在另一个HashMap中的HashMap。
Map<String, Map<String, String>> PropertyHolder
我能按照以下方式迭代父HashMap
:
Iterator it = PropertyHolder.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next();
System.out.println("pair.getKey() : " + pair.getKey() + " pair.getValue() : " + pair.getValue());
it.remove(); // avoids a ConcurrentModificationException
}
但是无法遍历子Map
,可以通过将pair.getValue().toString()
转换并使用,
和=
分隔来实现。是否有其他遍历方法?