can exception occur in recursion function ?

Posted by Yugandhar under Others on 9/10/2012 | Points: 10 | Views : 760 | Status : [Member] | Replies : 1
can exception occur in recursion function in java ?
if it occur how it will ?


Posted by: Sourabh07 on: 10/14/2012 [Member] Starter | Points: 25

In case of recursion, exception occurs when we did not specify the end point of the loop. let us take an example for the looping concept either in java or in c#, we have to follow three steps...
1) initiation of the loop eg: i=0
2) increment/decrement the loop accordingly eg: i++ or i-- respectively
3) end point eg: i<10

so, exception occurs in that case if we start the loop at i=1 and following the condition i>0 means the loop will not have a terminated point and it shows an error Stack overflow.

so, be ensure the loop follow the above overcome from the exception.


Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response