How to Iterate
List<Map<String, String>>
using streams..i have tried without streams and i was able to iterate.
for (Map<String, String> temp1 : maps){
for(Map.Entry<String, String> temp2: temp1.entrySet())
Is there a way to iterate using Streams..
You can use Stream.flatMap(...) to iterate each map entry from the list of maps.
List<Map<String, String>> maps = ...
maps.stream()
.flatMap(map -> map.entrySet().stream())
.forEach(entry -> System.out.println(entry));
From the docs:
Returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With