int[] array = new int[9];
int[][] matrix = { {0,1,2},
{3,4,5},
{6,7,8}};
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
array[i+j] = matrix[i][i];
}
}
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
So I expect the array to be set to {0,1,2,3,4,5,6,7,8,9}, but the out put is
00 01 02 43 44 45 86 87 88
This is just a side project to solve a soduku puzzle, yet this problem has always stumped me. I usually try to find a way to go around this, but I've gotten to the point where I want to know why this isn't working.