forEach Loop in Java


The forEach method in the Iterable interface allows you to iterate over collections more elegantly, using lambda expressions.

Source Code

List list = Arrays.asList("Apple", "Banana", "Cherry");
list.forEach(item -> System.out.println(item));
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments