我正在尝试在 Java 中创建一个类,该类构建一个类型的对象,该对象Action
包含三个整数并将其返回给我在数组中的另一个类history
,其中history
是类型数组Action
。当它被调用时,我立即得到一个无限循环;因此堆栈溢出。
错误 - 我打印了 1 行,它继续...
Exception in thread "main" java.lang.StackOverflowError
at sudokugame.Action.<init>(Action.java:7)
班级:
public class Action {
Action a;
public Action(int i, int o, int p){
a = new Action(i,o,p);
}
public void setAction(int n, int b, int c){
}
public Action getAction(){
return a;
}
}