【发布时间】:2014-10-18 08:57:46
【问题描述】:
char[][] boardGame = new char[10][10];
// this is suppose to create an array object
for (char[] row : boardGame)
{
Arrays.fill(row, 'a');
}
// this is suppose to fill the row in array with the char '*'
// and im using "Enhanced" for loops
for (int i = 0; i < boardGame.length; i++)
{
for (int j = 0; j < boardGame[i].length; j++)
{
System.out.print("|" + boardGame[i][j] + "|");
}
// in the for loop above isn't "i" and "j" been overwrite with
// numbers as I declare it int i = 0 and I update it if the
// condition is true i++
// how come it print|*||*||*||*||*|....instead of |1||2||3|...?
System.out.println();
}
在上面的内部for 循环中,“i”和“j”已被数字覆盖,因为我声明它为int i = 0,如果条件为truei++,我将更新它。
为什么打印的是|*||*||*||*||*|...而不是|1||2||3|...?
【问题讨论】:
-
你想让我们说什么?
-
你有什么问题?! stackoverflow.com/help/how-to-ask
-
我不明白你为什么希望它打印数字而不是星号。
标签: java arrays multidimensional-array