class Sample {
Sample s = new Sample();
static Sample sa = new Sample();
void check(Sample s) {
System.out.println(this.s == s);
}
}
public class Other
{ Other o=new Other();//line 27
static Other ot=new Other();
public static void main(String[] args) {
new Sample().check(new Sample().s);
}
}
输出: java.lang.StackOverflowError
在oca.Other。(Other.java:27)
在oca.Other。(Other.java:27)
在oca.Other。(Other.java:27)
在oca.Other。(Other.java:27)
在oca.Other。(Other.java:27)
。
。
。
谁能解释我为什么仅在非静态实例中发生错误?