Java 8 ForEach Example | Iterate Collection in Java

All the Collection Interfaces in Java (List, Set, Map etc) will be extending the Iterable interface as the super interface. In Java 8 a new method has been introduced for Iterating over collections in Java.

void forEach(Consumer<? super T> action)

In this Java 8, ForEach Example article lets see how to iterate through a List and Map with the new forEach Loop in Java 8. [Read more…]