Confusing output from infinite recursion within try-catch

前端 未结 7 2017
隐瞒了意图╮
隐瞒了意图╮ 2020-12-23 19:13

Consider the following code.

public class Action {
private static int i=1;
public static void main(String[] args)          


        
7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-23 20:02

    If the execution of println (or one of the methods called by it) causes a stack overflow, you will print the same i value from the catch clause of the enclosing main incarnation.

    The exact behavior is rather unpredictable as it depends on the stack space still available.

提交回复
热议问题