Created
June 19, 2024 13:31
-
-
Save Goliath/e1039902dd7b74cd1f68ba72e10df22f to your computer and use it in GitHub Desktop.
Simple code to test how many method invocations you can make before you get stackoverflow exception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RecursiveStackOverflow { | |
static int depth = 0; | |
private static void recursiveStackOverflow(long param) { | |
depth++; | |
recursiveStackOverflow(param); | |
} | |
public static void main(String[] args) { | |
try { | |
recursiveStackOverflow(1L); | |
} catch (StackOverflowError e) { | |
System.out.println("Maximum depth of the call stack is " + depth); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment