Odd Java StackOverflowError?
2022-09-04 22:22:14
为什么此代码会完全破坏输出?
public class Main {
public static void main(String[] args) {
System.out.println();
rec();
}
private static int rec() {
try {
return rec();
} catch(StackOverflowError e) {
System.out.println("Boo.");
return 0;
}
}
}
我得到的示例输出:Boo.Boo.Boo.Boo.Boo.Boo.Boo.Boo.Boo.