Java Exception Knowledge Summary

Source: Internet
Author: User
Tags throwable

First, paste the inheritance diagram between Java common exception classes

As can be seen from the diagram, the base class for Throwable,error and Exception class inheritance throwable,error down to awterror (not quite clear), IOError (Input Output Class), linkageerror (common in jar package conflicts) , Threaddeath (thread Class).

Error is generated and thrown by the virtual machine, which is a serious condition such as internal bugs in the JVM system or resource exhaustion (errors that the program cannot handle), which is the responsibility of the JVM, so that such unusual events cannot be recovered or captured after they occur. When error is generated, it eventually results in an application outage (JVM execution thread interruption). However, error can be translated in some situations, that is, error can be translated into exception or runtimeexception, so as to retrieve the serious negative effects of error generation.

The exception category is very large, first divided into two categories: RuntimeException and non-runtimeexception, (corresponding to unchecked exception and Checked Exception)

The runtimeexception class is a subclass of the exception class, which is called a run-time exception , and all runtime exceptions in Java are inherited directly or indirectly from the RuntimeException class. For runtime exceptions (runtime exception), they can be processed or not handled. It is not recommended to handle run-time exceptions.

non-runtimeexception: Exceptions in Java that inherit from exception and do not inherit from the RuntimeException class are non-runtime exceptions . In general, non-runtimeexception are generally external errors, which must catch exceptions to the try{}catch...finally statement block. It is also possible to write the throws of a Exception type , such as throws Exception, on a method that may occur in the exception of that type, throwing the exception to the outside layer, which may eventually be handled by the JVM. (such as the most common file read and write, database read and write operations)

Java Exception Knowledge Summary

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.