本文共 655 字,大约阅读时间需要 2 分钟。
Say you have a recursive method, and you post-increment/decrement a value in the recursive call. Why will this result in a stack overflow exception when a pre-increment/decrement will not?
Ex.
numberCount(currentNumber++); //Stack overflow exception
numberCount(++currentNumber); //No stack overflow exception
Thanks in advance for any clarification.
解决方案
The first
numberCount(currentNumber++); //Stack overflow exception
is equivalent to:
numberCount(currentNumber);
currentNumber += 1;
while the the second
numberCount(++currentNumber); //No stack overflow exception
is equivalent to
currentNumber += 1;
numberCount(currentNumber);
Need I explain more?
转载地址:https://blog.csdn.net/weixin_34569101/article/details/118835786 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!