Java Tutorial: Printing an Array Using a For Loop

0 0 0 0 0
[0] [1] [2] [3] [4]

i

Main Memory

Variable Value
1
int[] numbers = { 9, 80, 14, 23, 2 };
2
for (int i = 0; i < numbers.length; i++)
3
{
4
    System.out.print( numbers[i] + " " );
5
}
6
System.out.println();

Output