Similar Posts

Subscribe
Notify of
6 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
iQa1x
1 year ago

Return addresses land on the stack (Spezieller area in the store), and if you build an infinite recursion, it will eventually run over.

When you call a function, the return address is placed on the stack. When returning, it is then read by the stack to jump into the line after the call (so you can call up the function from somewhere in the code and the computer knows where it has to return after performing the function). You now retrieve the function in the return line (with Graete+1) only when this call is processed, the return is executed. Since the just called function calls itself again, it never comes to return. Instead, a return address will land on the stack with each call, which is eventually full. Evtl. just want “return Graete+1”?

guteantwort626
1 year ago

The code leads to an endless loop, since the function is repeatedly called (recursion) and a corresponding termination condition is missing. This then leads to the StackOverflow.

NorbertWillhelm
1 year ago

Because the function as it is written leads to endless recursion.

When the function is called up, the function variable (again) lands on the stack, which overflows because the function calls itself endlessly. This leads to a stack overflow.

teehouse
1 year ago

You have an endless recursion. Of course, that’s where the stack goes.

orochi02
1 year ago
Reply to  Gutofruto

has something to do with the storage model in java. inform you about the java stack