Search code examples
exceptionrecursionstackstack-overflow

Without using recursion how can a stack overflow exception be thrown?


Without using recursion how can a stack overflow exception be thrown?


Solution

  • If you call enough methods, a stack overflow can occur anytime. Although, if you get stack overflow errors without using recursion, you may want to rethink how you're doing things. It's just so easy with recursion because in an infinite loop, you call a ton of methods.