Iterate through nested hashmap

前端 未结 2 783
旧时难觅i
旧时难觅i 2020-12-15 07:42

How would I go about iterating through a nested HashMap?

The HashMap is setup like this:

HashMap

        
2条回答
  •  余生分开走
    2020-12-15 08:27

    Java 8 lambdas and Map.forEach make bkail's answer more concise:

    outerMap.forEach((letter, nestedMap) -> {
        //...
        nestedMap.forEach((name, student) -> {
            //...
        });
        //...
    });
    

提交回复
热议问题