我得到:'
需要意外类型:变量
找到:值'在标记的行(*)
for (int i = 0; i < boardSize; i++) {
for (int j = 0; j < boardSize; j++) {
rows[i].getSquare(j) = matrix[i][j]; // * points to the ( in (j)
columns[j].getSquare(i) = matrix[i][j]; // * points to the ( in
int[] b = getBox(i, j);
int[] boxCord = getBoxCoordinates(i + 1, j + 1);
boxes[b[0]][b[1]].getSquare(boxCord[0], boxCord[1]);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的Row类:
private Square[] row;
Row(int rowCount) {
this.row = new Square[rowCount];
}
public Square getSquare(int index) {
return this.row[index];
}
Run Code Online (Sandbox Code Playgroud)
请指出我在这里做错了什么,帮助我.
提前致谢.
Mic*_*rdt 10
您不能将某些内容分配给方法的返回值.相反,您需要向该类添加一个setSquare()方法Row:
public Square setSquare(int index, Square value) {
this.row[index] = value;
}
Run Code Online (Sandbox Code Playgroud)
并像这样使用它:
rows[i].setSquare(j, matrix[i][j]);
Run Code Online (Sandbox Code Playgroud)