try {
if (check) {
while (true) ;
} else {
System.exit(1);
}
} finally {
clear();
}
Q: Is there a case where clear() never gets executed?
I personally feel that there are no cases where clear() will not be executed.
System.exit(1) prevents the finally clause from running.
Basically a finally block is executed after a try/catch regardless if the try or the catch returned normally or exceptionally.
A System.exit however prevents the block from returning at all.
while(true) ; will obviously block indefinitely. just assumed that the while (true) ; was a stub for something that made more sense 🙂