This is equivalent to something like this:
while(true) {
try {
// Do something
} catch(Exception e) {
if(someCondition)
break;
}
}
The loop will run until it is explicitly broken by the exception handler.
Notice that this (and your for(;;)
) will be running forever if someCondition
is never set to true
.
If you insist to do this endless loop, I would modify it to something like:
boolean terminateLoop = false;
while(true) { // for(;;) {
try {
// Do something
if(someTerminationCondition)
terminateLoop = true;
} catch(Exception e) {
if(someCondition)
break;
} finally {
if(terminateLoop)
break;
}
}
Note. I wouldn't use this on any real world algorithm... it is just a "theoretical" solution to avoid an endless loop.
The for
loop is meant to do things based on specific increments (or decrements) of a variable... I like to call it a "deterministic" loop (I'm not quite sure if it is an appropriate name). If whatever you need to do doesn't gives you a way to use specific increments (or decrements) of a variable as a break condition, I think you should consider using while
or do... while
loops (which I like to call "non-deterministic" loops).