Tell me how this loop works.

So what i have in my head is this:

Step 1) arr1[i] = arr1[1-1] + 1

Step 2) arr1[i] = arr1[0] + 1

Step 3) ???

what is most troubling is that there is arr1[0] which i dont know how it existed from the above steps. Next is how arr1[0] is 0 when arr1[0] doesn't even exist. Shouldn't it have started out with arr1[1]? Since i = 1?

Code:

` for (i = 1;i <= max;i++)`

arr1[i] = arr1[i-1] + i;;

the whole code is this:

Code:

`System.out.print("Please enter the max number:");`

int max = input.nextInt();

int[]arr1 = new int[max+1];

int[]arr2 = new int[max+1];

int[]arr3 = new int[max+1];

int i = 1;

// For-loop to calculate

for (i = 1;i <= max;i++)

arr1[i] = arr1[i-1] + i;

for (i = 1;i <= max;i++)

arr2[i] = arr2[i-1] + i;

for (i = 1;i <= max;i++)

arr3[i] = arr3[i-1] + i;

for (i = 0; i <= max; i++)

System.out.println("Arr1 " + arr1[i] + " Arr2 " + arr2[i] + " Arr3 " + arr3[i]);

System.out.println("Sum of All is " + arr1[max]);

what it prints out:

Code:

`Please enter the max number:5`

Arr1 0 Arr2 0 Arr3 0

Arr1 1 Arr2 1 Arr3 1

Arr1 3 Arr2 3 Arr3 3

Arr1 6 Arr2 6 Arr3 6

Arr1 10 Arr2 10 Arr3 10

Arr1 15 Arr2 15 Arr3 15

Sum of All is 15

Any help would be appreciated. Thanks!:)