class Size{
Size(){
}
//public final Size SMALL = new Size();//infinite loop
final Size as = new Size();//infinite loop
//static Size aw = new Size();//No infinte loop
}
class b{
static public void main(String ftr[]){
Size z = new Size();
}
}
當靜態尺寸aw等於新Size();上述程序運行時出現錯誤。 看到的場景之下,該程序與運行時:請在初始化java類的同時初始化以下內容
public final Size SMALL = new Size();// infinite loop is happening
final Size as = new Size();
一個無限循環的發生,節目是給
Exception in thread "main" java.lang.StackOverflowError
at Size.<init>(Interesting.java:6)
at Size.<init>(Interesting.java:6)
誰能給我解釋一下,或者指向我的地方,我可以找到背後的原因。