Home >>Java Programs >for each loop in Java
In this example, we will see a Java program in which we will see for-each loop in Java.
For-each loop is used to execute a block of statements. It works on the collections and iterates over each element of the sequence on by one and executes them.
Program:
public class Main
{
public static void main(String[] args)
{
int array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
for (int i : array)
System.out.println(i);
}
}