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:
parent
66eb61eff4
commit
10613742da
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue