Java8 forEach loop example

forEach Signature
forEach(Consumer<? super T> action)
Working :Performs the provided action for each element of the Iterable until all elements have been processed or the action throws an exception.Your code gives hint about what should be iterated.The internal implementation of forEach determines how to iterate it.This is delegation we don’t write the implementation we used to write earlier.

Java7 Code:

Inherited from :Iterable interface.

Leave a Reply

Your email address will not be published. Required fields are marked *