can exception occur in recursion function ?

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




Responses

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

Up
0
Down
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 ...it means the loop will not have a terminated point and it shows an error Stack overflow.

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

Sourabh07

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

Login to post response