In this example we will show the method to loop through an array with for-each in Java.
Source Code
package com.beginner.examples;
public class LoopArray {
public static void main(String[] args) {
String[] strs = {"a", "b", "c"};
for (String s : strs) { // loop through an array
System.out.println(s);
}
}
}
Output:
a
b
c