Java Exception System

Source: Internet
Author: User

The exception class level for Java is clearly shown on this map.

Throwable: as an ancestor of all exceptions, there are two subclasses that derive exception and error two, respectively.

Error: The presence of error indicates that the JVM is having a problem as a running environment, causing the program to throw an error and crash.

Exception: The exception that the program runs itself. RuntimeException and IOException are derived from two major classes.

runtimeexception: runtime exceptions, including logically such as array out-of-bounds, null pointers, type conversion errors, classes not found, and so on. Logic-related exceptions should be logically avoided, the compiler does not check, and does not require certain processing.

non-runtime exception: not processed, compilation does not pass. such as IOException and SqlException, and user-defined exceptions.


Exceptions are handled in such a way that:

capture:try...catch ...

Throw: give a layer of processing. Throws an exception when defining a method using throws. In the code, the throwis used instead of the active throw exception. Don't be silly in the future, wrong but to hit their own butt.


Multiple exceptions occur at the same time, and the exception is an inheritance relationship, how do I run it?

The answer is:

Exception as an ancestor of all exceptions, if placed in front of other exceptions, will compile the exception, not through the grammar check.

Otherwise, the exception is placed at the end, so the most exact matching exception will be executed.


Java Exception System

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.