误差来源于此线BoardState ADDME =新BoardState();
出于某种原因,这是在指向非静态变量是“新”。 我不清楚新并不意味着是一个变量,而不是我如何修正这个错误。
寻找通过计算器记录该误差通常来自其通常通过使方法静态或完全绕过方法解决的非静态方法。 Ť
下面这段代码是引用前及本声明之后,到底是怎么回事。
public class IntelligentTicTacToe extends TicTacToe {
public class BoardState{
public String TTTState;
public int[][] defensiveOppsArray;
public int[][] offensiveOppsArray;
public String str;
public int cnt;
}
public static ArrayList<BoardState> memory = new ArrayList<BoardState>();
public static boolean makeMove(){
char[] oArray = new char[TicTacToeArray.length];
int[][] defensiveOppsArray = new int[TicTacToeArray.length][TicTacToeArray.length];
int[][] offensiveOppsArray = new int[TicTacToeArray.length][TicTacToeArray.length];
int[][] sumOppsArray = new int[TicTacToeArray.length][TicTacToeArray.length];
//converts our Array into a String
String x = convertTTTArrayToString();
//Goes through the conditions to see if we have it in memory or if we must go through all the conditions
boolean matchFound = false;
for(int i=0; i < memory.size(); i++){
BoardState element = memory.get(i);
if(element.str.equals(x)){
System.out.println("Match Found");
matchFound = true;
}}
if(!matchFound){
BoardState addme = new BoardState();
addme.str = x;
addme.cnt = 1;
memory.add(addme);
}
} ....