A Java program can catch exceptions by using a combination of the try, catch, and finally blocks.


  • The try block identifies a block of code in which an exception can occur.
  • The catch block identifies a block of code, known as an exception handler, that can handle a particular type of exception.
  • The finally block identifies a block of code that is guaranteed to execute, and is the right place to close files, recover resources, and otherwise clean up after the code enclosed in the try block.

Featured Post

US Tech Companies Reconsider Saudi Investment

The controversy over the death of Saudi Arabian journalist Jamal Khashoggi has shined a harsh light on the growing financial ties between Si...