I have to create while loop which handle two counter values which refer two different max counter values
like, i and j = 1, iMax=2 and jMax=3
While loop contains code who throw two different kind of exceptions, exception 1 increase counter i and exception 2 increase counter j
After counter reach max limit throw exception
Suggest most effective way to handle While loop
I have tried with,
While(i<=iMax && j<=jMax) {
// process
catch(Exception1 ex) {
if(i==iMax) throw ex;
i++;
}
catch(Exception2 ex) {
if(j==jMax) throw ex;
j++;
}
}