Skip to content

Instantly share code, notes, and snippets.

@bchetty
Created April 24, 2014 20:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bchetty/11268991 to your computer and use it in GitHub Desktop.
Save bchetty/11268991 to your computer and use it in GitHub Desktop.
Java - Recursion Depth
**
* Inception
*
* @author Babji, Chetty
*/
public class Inception {
public static void main(String[] args) {
Inception inception = new Inception();
inception.dream(0);
}
public void dream(long count) {
try {
dream(count + 1); //Dream inside a Dream
} catch (StackOverflowError SOF) {
System.out.print("Recursion Depth : " + count);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment