In this example we will show you how to use for-each loop in Java.
Source Code
package com.beginner.examples;
public class ForEachLoop {
public static void main(String[] args) {
String[] strs = {"a", "b", "c", "d"};
for (String str : strs) { // for-each loop
System.out.println(str);
}
}
}
Output:
a
b
c
d