Separating Error Handling Code

Java Exception Handling: Try Catch Finally

When application crashes the JVM excludes it from any further execution. This means application halts abruptly. In Java Exception Handling is useful to avoid application crashes. Exception handles error condition and takes a safer path in the execution flow. The exception also makes code more readable as the error handling code stays in a separate section from the normal business logic code. In this example, we will see how to handle exception using Try & Catch blocks. We will also see the role of Finally block.