Introduction to Java Exceptions

Source: Internet
Author: User

Anomalies are different from normal, and they are not the same, and errors occur. An issue that blocks the execution of the current method or scope, called an exception.
All classes in Java that are related to exceptions inherit from the Throwable class, the Throwable class has two sons, one is the error class, and the other is the exception class.
  

The error class exception includes a virtual machine error, thread deadlock, and so on, the error occurs, and the program crashes completely.
Exception abnormal appearance, indicating that there are problems in the program, may be encoding, environment, user operation input and other causes of the exception, exception has a lot of sons, common for RuntimeException (runtime exception), there are other exceptions. RuntimeException is a non-check exception, while other exceptions are check exceptions.
  

There are many situations that cause runtimeexception anomalies, such as the property fire method that references an empty object, the array access bounds, the wrong type conversion, and the exception caused by arithmetic (for example, except 0). The above four cases correspond to null pointer exception (nullpointerexception), array subscript out-of-bounds exception (arrayindexoutofboundsexception), Type conversion exceptions (classcastexception) and arithmetic exceptions (ArithmeticException), and, of course, many other run-time exceptions, which are subclasses of RuntimeException, are not described here.
Runtime exceptions are automatically thrown by the Java virtual machine and automatically captured, while the run-time exception occurs in most cases where the name code itself is problematic and should logically improve the code
  

Check for exceptions, the cause of the inspection anomalies may be a variety of wonderful reasons, such as file exceptions (IOException), SQL Exception (SQLException), and so on, unlike RuntimeException, You need to manually add captures and process statements for checking exceptions

Introduction to Java Exceptions

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.