Java Exception class

Source: Internet
Author: User
Tags throwable

Exception class Hierarchy

The exception class hierarchy starts with the java.lang.Throwable class. When an exception is thrown, it must be the Throwable object of the class or any of its subclasses.

catchThe parameters of a block must be of Throwable type or its subclasses, for example: Exception , ArithmeticException , and IOException so on.

You can create your own defined exception class by inheriting an exception class class.

Organization arranges multiple catch blocks

The Java runtime selects the appropriate catch blocks and looks for the appropriate blocks from the first block in the order they are catch started catch .
tryMultiple blocks of a block catch must be arranged from the most specific exception type to the most common exception type.

The following code uses catch a valid sequence of multiple blocks.

ArithmeticExceptionA class is a RuntimeException subclass of a class.

If both exceptions are try handled in blocks of the same catch block, then the most specific type, that is ArithmeticException , must precede the most common type, before the RuntimeException exception class.

Click on the link to view the details

Java Exception class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.