Friday, 27 September 2013

break; inside a try block

break; inside a try block

As far as I am concerned after an exception is thrown the code that
follows is not executed in the try block so my question is - will it be a
good habit doing something like:
do{
// read input
try{
// code that throws exception
break;
}
catch (SomeException e){
// do some stuff here
}
}
while (true);
I wont to force the user to input until the input is valid and doesn't
throw an exception, is there a more elegant way to do it in case this is a
bad habit?

No comments:

Post a Comment