For-each loop

For-each loop

For-each loop — is an enhanced version of the for loop, designed specifically for iterating over arrays and collections in a clean, concise manner.

for (ElementType element : collection) {
    // Loop body
}
String[] fruits = {"Apple", "Banana", "Cherry"};

for (String fruit : fruits) {
    System.out.println(fruit);
}

Related concepts

For-each loop — Structure map

Clickable & Draggable!

For-each loop — Related pages: