Java 初始化数组元素范围的更优雅的方法
我已经有好几年没有使用java了。我想有一个更好的方法来写这个,不知道如何用谷歌搜索这个问题Java 初始化数组元素范围的更优雅的方法,java,Java,我已经有好几年没有使用java了。我想有一个更好的方法来写这个,不知道如何用谷歌搜索这个问题 boardSpots[0][1] = new Pawn(); boardSpots[1][1] = new Pawn(); boardSpots[2][1] = new Pawn(); boardSpots[3][1] = new Pawn(); boardSpots[4][1] = new Pawn(); boardSpots[5][1] = new Pawn(); boardSpots[6][1]
boardSpots[0][1] = new Pawn();
boardSpots[1][1] = new Pawn();
boardSpots[2][1] = new Pawn();
boardSpots[3][1] = new Pawn();
boardSpots[4][1] = new Pawn();
boardSpots[5][1] = new Pawn();
boardSpots[6][1] = new Pawn();
boardSpots[7][1] = new Pawn();
for(int i=0;i<8;i++){
boardSpots[i][1]=新典当();
}
用于(int i=0;i<8;i++){
boardSpots[i][1]=新典当();
}
用于(int i=0;i<8;i++){
boardSpots[i][1]=新典当();
}
用于(int i=0;i<8;i++){
boardSpots[i][1]=新典当();
}
为循环使用嵌套的:
for (int i = 0; i < boardSpots.length; i++) {
for (int j = 0; j < boardSpots[i].length; j++) {
boardSpots[i][j] = new Pawn();
}
}
for(int i=0;i
为
循环使用嵌套的:
for (int i = 0; i < boardSpots.length; i++) {
for (int j = 0; j < boardSpots[i].length; j++) {
boardSpots[i][j] = new Pawn();
}
}
for(int i=0;i
为
循环使用嵌套的:
for (int i = 0; i < boardSpots.length; i++) {
for (int j = 0; j < boardSpots[i].length; j++) {
boardSpots[i][j] = new Pawn();
}
}
for(int i=0;i
为
循环使用嵌套的:
for (int i = 0; i < boardSpots.length; i++) {
for (int j = 0; j < boardSpots[i].length; j++) {
boardSpots[i][j] = new Pawn();
}
}
for(int i=0;i
您不能在循环中创建它们吗?删除问题?:现在太晚了,我要做的就是处理这些问题。你能不能在一个循环中创建它们?删除这个问题现在太晚了,我要做的就是处理这些问题。你能不能在一个循环中创建它们?删除这个问题现在太晚了,我要做的就是处理这些问题。你能不能在一个循环中创建它们?删除这个问题托托现在迟到了,我只能忍受耻辱了