Some of these exceptions are caused by user error, others by programmer error, and others by physical resources that have failed in some manner.Based on these, we have three categories of Exceptions.
But don’t expect us to be anything other than civil.
For the first time ever, I had stumped my brilliant lawyer father.
You just need to extend the predefined Exception class to create your own Exception. The following Insufficient Funds Exception class is a user-defined exception that extends the Exception class, making it a checked exception.
An exception class is like any other class, containing useful fields and methods.
When an exception occurs, that exception occurred is handled by catch block associated with it.
Every try block should be immediately followed either by a catch block or finally block.If the type of exception that occurred is listed in a catch block, the exception is passed to the catch block much as an argument is passed into a method parameter.The following is an array declared with 2 elements.This continues until the exception either is caught or falls through all catches, in which case the current method stops execution and the exception is thrown down to the previous method on the call stack.Here is code segment showing how to use multiple try/catch statements. You need to understand them to know how exception handling works in Java.