1// Java program to iterate over an array
2// using for loop
3import java.io.*;
4class GFG {
5
6 public static void main(String args[]) throws IOException
7 {
8 int ar[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
9 int i, x;
10
11 // iterating over an array
12 for (i = 0; i < ar.length; i++) {
13
14 // accessing each element of array
15 x = ar[i];
16 System.out.print(x + " ");
17 }
18 }
19}