Exception Handling in Java

Exception Handling in Java

The way toward changing over framework mistake messages into easy to use blunder message is known as Exception taking care of. This is one of the capable component of Java to handle run time blunder and keep up ordinary stream of java application.

Special case

An Exception is an occasion, which happens amid the execution of a system, that disturbs the typical stream of the project's Instructions.

Why use Exception Handling

Taking care of the special case is only changing over framework blunder created message into easy to understand mistake message. At whatever point a special case happens in the java application, JVM will make an object of suitable exemption of sub class and produces framework blunder message, these framework created messages are not justifiable by client so need to change over it into easy to use mistake message. You can change over framework mistake message into easy to understand blunder message by utilizing special case taking care of highlight of java.
For Example: when you partition any number by zero then framework produce/by zero so this is not reasonable by client so you can change over this message into easy to understand mistake message like Don't enter zero for denominator.

Hierarchy of Exception classes

Type of Exception

  • Checked Exception
  • Un-Checked Exception
  • Checked Exception
Checked Exception are the special case which checked at arrange time. These special case are specifically sub-class of java.lang.Exception class.
Just for recollect: Checked means checked by compiler so checked exemption are checked at gather time.
Un-Checked Exception
Un-Checked Exception are the special case both recognizes or raised at run time. These special case are specifically sub-class of java.lang.RuntimeException class.
Note: continuously application for the most part we can deal with un-checked special case.
Just for recall: Un-checked means not checked by compiler so un-checked exemption are checked at run-time not incorporate time.
unchecked special case

Taking care of the Exception

Taking care of the special case is only changing over framework blunder produced message into easy to use mistake message in others word at whatever point an exemption happens in the java application, JVM will make an object of proper exemption of sub class and creates framework blunder message, these framework produced messages are not reasonable by client so need to change over it into easy to use blunder message. You can change over framework mistake message into easy to use blunder message by utilizing special case taking care of highlight of java.

Utilize Five catchphrases for Handling the Exception

  • try
  • catch
  • finally
  • throws
  • throw