我在构建类时遇到问题,
以下代码抛出异常
public class Agent extends Board{
private static boolean arrow;
private static boolean backmove;
private static boolean gotGold;
private static int atlocationX;
private static int atlocationY;
private static int faceposition;
private static int pathcounter;
public boolean temporaryGold;
public boolean temporaryWumpus;
public boolean temporaryStench;
public boolean temporaryBreeze;
public boolean temporaryPit;
int agentgui = 0;
int label = 0;
Block blockstorage[][] = new Block[4][4];
KnowledgeBase kb = new KnowledgeBase();
public Agent() {
super();
}
public void Agent(){
Agent.arrow = true;
Agent.faceposition = 2;
Agent.atlocationX = 0;
Agent.atlocationY = 0;
Agent.backmove = false;
Agent.gotGold = false;
Agent.pathcounter = 1;
}
}
问题是,当我尝试添加
Agent agent = new Agent();
在我的其他一些课程中,例如:
public class Board {
Agent agent = new Agent();
}
它返回一个错误:
线程“AWT-EventQueue-0”中的异常 java.lang.StackOverflowError
我也尝试过,但还是一样。
是什么导致了这个异常?