Exceptions should be an exceptional case, and not every time the code is executed. Therefore, it is better to check the condition before try ing!
if (condition) { try { //something } catch(SomeEx ex) {} }
Make sure that if (condition) does not throw an Exception .
It depends on your use and functionality. For example, this would be better:
if (someObject!=null) { try { someObject.getSomething(); // getSomething() potentially throws some Exception } catch(SomeEx ex) {} }
What does the JVM actually do when entering a try block?
Read the JVM spec 2.10 .
source share