I'm having trouble tracing some code to get the output:
int[] a = new int[5];
for (int i = 0; i < a.length; i++)
{
a[i] = i*3-1;
}
for (int i = a.length-1; i >= 0; i--)
{
System.out.print(a[i] + " " );
}
This outputs:
11 8 5 2 -1
What I don't understand is why the second variable 'i' is being put back in the formula from the first For Loop. How can I connect these two loops? The array is defined in the first loop, so why does it affect the second? I don't understand the relation, perhaps I'm just missing it.