• Post Reply Bookmark Topic Watch Topic
  • New Topic

StackOverflowError  RSS feed

 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

So Java doesn't support tail recursive calls ...

I thought a code like this would just make the program run forever:

void go() { go(); }
 
Leandro Coutinho
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forget about it. This is because otherwise Java couldn't keep track of the method calls. (I think) =)
 
Bartender
Posts: 1561
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Leandro Coutinho wrote:Forget about it. This is because otherwise Java couldn't keep track of the method calls. (I think) =)


No, any time a method is called, a bit of stack memory is used, and unending recursion will logically cause the JVM to run out of stack memory. This is no different from C.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!