Answer the question
In order to leave comments, you need to log in
What is the condition for throwing a StackOverflowError?
Let's say we have a method
public static void foo(){
foo();
}
Answer the question
In order to leave comments, you need to log in
Well, it is obvious that the compiler has a maximum allowable size of the call stack.
When a function is called, a certain set of data is pushed onto the stack. With normal (non-tail) recursion, each nested function call will increase the stack by N bytes. At a certain point (at which point it depends on several factors, including the number and types of function parameters, the maximum stack size), the stack will have nowhere to grow, and this error will occur.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question