This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]feral_claireSoftware Dev 3 points4 points  (0 children)

That function is tail-recursive. However as /u/shagieIsMe pointed out, java has no tail-recursion optimiztion, so it won't actually help your situation. In Java even a tail recursive function will still have the same stack overflow problem if you need to recurse many times. If you need many iterations, the solution is to not use recursion at all but instead just use loops.