Try Catch Performance Java

In short, the check is way faster. You should use the check because:

  • Exceptions are EXPENSIVE! A stack trace must be created (if used, eg logged etc) and special flow control handled
  • Exceptions should not be used for flow control – Exceptions are for the “exceptional”
  • Exceptions are the code’s way of saying “I can’t handle this situation and I’m giving up… you deal with it!”, but here you can handle it… so handle it

Leave a Comment