Conventional For Loop vs Enhanced For Loop : <p>This code: </p>

<pre><code>import java.util.*;
import java.io.*;

class TestClass {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int arr[] = new int[n];
        for(int i = 0; i &lt; n; i++) arr[i] = sc.nextInt();

        for(int i : arr) System.out.println(arr[i]);



    }
}
</code></pre>

<p>Outputs: </p>

<pre><code>2
3
4
1
2
</code></pre>

<p>With this Input: </p>

<pre><code>5 1
1 2 3 4 1
</code></pre>

<p>On the other hand 
This Code:</p>

<pre><code>import java.util.*;
import java.io.*;

class TestClass {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int arr[] = new int[n];
        for(int i = 0; i &lt; n; i++) arr[i] = sc.nextInt();

        for(int i = 0; i &lt; n; i++) System.out.println(arr[i]);



    }
}
</code></pre>

<p>Outputs:</p>

<pre><code>1
2
3
4
1
</code></pre>

<p>In the first code snippet the foreach loop should print the elements of the array but I don't understand what are those numbers and how those numbers are the elements of that array.</p>
