I want to know if I use one or two try catch in a while loop, does this affect the performance or not?
Example code below:
try {
// some code
....
try {
// some code
...
} catch(Exception e) {
if(e is not catchable) {
//throw it as MyException(e);
}
}
// some code
...
} catch(Exception e) {
if(e is my Exception) {
then do somthing
...
} else { // is other Exception
if(e is not catchable) {
then stop the loop
}
// else catch it and continue
}
}
What about if else
if used instead, then which one will be the good idea?
If someone knows pleas tell me does it affect performance or not, if yes then why.
My question maybe asked by someone else before, but I also want to know about if-else
if it is better then try-catch
.
Edit:
I know if throws Exception
then for catching it needs some time, but how about if the program goes whit no Exception jut like:
// some code
....
// some code
....
// some code
....
Thanks!