了解 Java 堆栈
2022-09-01 17:44:35
有以下代码:
public class Main {
public static void main(final String[] args) throws Exception {
System.out.print("1");
doAnything();
System.out.println("2");
}
private static void doAnything() {
try {
doAnything();
} catch (final Error e) {
System.out.print("y");
}
}
}
还有输出:
1yyyyyyyy2
为什么它打印“y”八次而没有更多。遇到 Java 时如何调用?println()
StackOverflowError