如何在Java中迭代下面的Nestested HashMap

时间:2016-04-27 15:00:47

标签: java collections

我想迭代下面的HashMap。我想从中检索密钥和值。

HashMap<String,List<HashMap<String, List<String >>>> maps = new HashMap<String, List<HashMap<String, List<String>>>>();

1 个答案:

答案 0 :(得分:4)

像这样:

HashMap<String,List<HashMap<String, List<String >>>> maps = new HashMap<>();
for (Map.Entry<String, List<HashMap<String, List<String>>>> entry : maps.entrySet()) {
    for (HashMap<String, List<String>> map : entry.getValue()) {
        for (Map.Entry<String, List<String>> subEntry : map.entrySet()) {
            for (String value : subEntry.getValue()) {
                System.out.println(value);
            }
        }
    }
 }