For-each statement in Java
In Java, the
for-each statement allows you to directly loop through each item in an array or
ArrayList and perform some action with each item.
When creating a
for-each statement, you must include the
for keyword and two expressions inside of parentheses, separated by a colon. These include:
The handle for an element we’re currently iterating over.
The source array or
ArrayList we’re iterating over.