我想创建某种列表来存储数组'表'中的值。 (?我使用的ArrayList这里,但我应该用一个列表,而不是),但每次我尝试编译的时候,它会引发以下错误:错误:找不到符号ArrayList
找不到符号 符号:类的ArrayList 位置:类players.TablePlayer
代码如下。
public class TablePlayer extends Player {
int[][] table;
ArrayList goodMoves;
public TablePlayer(String name) {
super(name);
}
@Override
public int move() {
int oppLast = opponentLastMove();
int myLast = myLastMove();
if (!isLegalMove(oppLast)) {
return 0; // temporary
}
if (wonLast()) {
table[oppLast][myLast] = 1;
table[myLast][oppLast] = -1;
}
if ((wonLast() == false) && (oppLast != myLast)) {
table[oppLast][myLast] = -1;
table[myLast][oppLast] = 1;
}
for (int i = 0; i < table.length; i++) {
for (int j = 0; j < table.length; j++) {
if (table[i][j] == 1) {
goodMoves.add(table[i][j]);
}
}
}
return oppLast; // temporary
}
@Override
public void start() {
int[][] table = new int[7][7];
ArrayList<int> goodMoves = new ArrayList<int>();
}
}
任何帮助将是伟大的,谢谢!
import java.util。*; –
听起来像你刚刚错过了导入。 –
一个体面的Java IDE会帮助你。 – maba