What is the maximum depth of the java call stack? (#14428)

* What is the maximum depth of the java call stack?

* What is the maximum depth of the java call stack?
This commit is contained in:
Michael Olayemi 2023-07-21 01:42:48 +00:00 committed by GitHub
parent 66eb61eff4
commit 10613742da
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package com.baeldung.callstack;
public class RecursiveCallStackOverflow {
static int depth = 0;
private static void recursiveStackOverflow() {
depth++;
recursiveStackOverflow();
}
public static void main(String[] args) {
try {
recursiveStackOverflow();
} catch (StackOverflowError e) {
System.out.println("Maximum depth of the call stack is " + depth);
}
}
}