Javaで2D配列を使用して、このようなものを設計するにはどうすればよいですか?
A B C
15 15 200
20 20 200
25 25 200
30 30 200
35 35 200
40 40 200
45 45 200
50 50 200
55 55 200
60 60 200
int[] A = { 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 };
int[][] name = new int[3][10];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 10; j++) {
name[i][j] = A[i]; // this prints out fine
name[i][j] = A[i]; // this also prints out fine
name[i][j] = 200; // but when I put this piece of code, it doesn't print the two
//above ones but instead it prints 200 on a 10 row by 3` column table.
for (int j = 0; j < 10; j++)
System.out.println(name[0][j] + " " + name[1][j] + " " + name[2][j]);
}
}
}
「name[i][j] = 200;」以外はすべて機能します。これを置くと、これだけが印刷され、他には何も印刷されません