本文介绍了错误:无法找到符号的ArrayList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建某种列表存储在阵列'表'的值。 (?我使用的ArrayList这里,但我应该用一个列表,而不是),但每次我尝试编译的时候,它引发以下错误:
I'm trying to create some kind of list to store values from the array 'table'. (I'm using a arraylist here, but should I be using a list instead?) However, every time I try to compile, it throws the following error:
找不到符号
符号:类的ArrayList
位置:类players.TablePlayer
cannot find symbolsymbol : class ArrayListlocation: class players.TablePlayer
在code如下。
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>();
}
}
任何帮助将是巨大的,谢谢!
Any help would be great, thanks!
推荐答案
你有没有在文件顶部的import语句?
Do you have an import statement in the top of the file?
import java.util.ArrayList;
这篇关于错误:无法找到符号的ArrayList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!