When does StackOverflowError occur? [duplicate]
问题 This question already has answers here : What is the maximum depth of the java call stack? (4 answers) Closed 5 years ago . According to Oracle, a StackOverflowError is: Thrown when a stack overflow occurs because an application recurses too deeply. I know what recursion is and normally recursive functions, if not terminated properly, lead to StackOverflowError. To check the number of recursive calls that happen before StackOverflowError is thrown, I wrote this code: package ErrorCases;