I'm trying to figure out how nested for loops for initializing variables work. I looked at another question on here that initialized values in a 2D array from 1 to 15 which seemed reasonable using the code:
for (int i = 0; i < row.length; i++) {
for (int j = 0; j < row[0].length; j++) {
row[i][j] = (i * row[0].length) + j;
}
}
I'm trying to extend that idea so that another array has the pattern as follows:
{0, 9,18,27,36,45,54,63,72} //row0...row8
{ 1,10,19,28,37,46,55,64,73}
It obvious that once a row completes a number is incremented by 1 and you keep adding 9 until you get to the end of the row. How is this represented in code? Solution to this problem would be great but a more general approach would be appreciated more if possible. My guess is that the headings for the for loop statements don't change but rather its the assignment equation that does.