In the following scenario,
public void fooMethod() { try { methodToCall(); }catch( FooException exception ) { methodToCall(); } } private int methodToCall() throws FooException { throw new FooException(); } I want to callmethodToCall (for example) 10 times to try if it succeeds.
Because of the fact that in the catch block, no exception is caught and with the above given example, the methodToCall is called two times in total (one in the try block and one in the catch block.)
How should I design the code so that methodToCall will be called 10 times even if it throws the given exception.
Edit
The actual fooMethod is much more complicated than this and I cannot call it recursively because several other jobs are done than before this try-catch clause.