Junior — Middle
What does the For Each method return in a functional interface?
sobes.tech AI
Answer from AI
The forEach method in the Java functional interface does not return any value — its return type is void. It is used to iterate over elements of a collection and perform a specified action on each element.
Example:
List<String> list = Arrays.asList("a", "b", "c");
list.forEach(item -> System.out.println(item));
Here, forEach simply applies a lambda expression to each element without returning a result.