hello all,
I have a recursive method in a java program.
the main program contains a for loop which calls the recursive method for a certain number of times.
the recursive method obviously calls itself. so I have stacks generated during the program execution.
how can I end the recursive method when it has called itself more than once.
and return back to the main program for the next iteration?
program structure is something like this:
private method (int, string){
// some code
//
method (int, string)
// Say that I want to return to main() here
}
public main () {
// some code
//
for (int i = 0; i <= somenum; i++) {
// some code
method (int, string) // i'll have different argument values for each call
}
}
I know about System.exit(). But that stops the program execution.
I need to keep the method running for the next "for" iteration.
Also "return;" will pass program execution to the previous stack. which I don't want.
Any Ideas/Suggestins??