Java Exception &&runtimeexception exception

Source: Internet
Author: User


Java exceptions can be divided into 3 types:

(1) Compile-time exception: Java.lang.Exception

(2) Run-time exception: Java.lang.RuntimeException

(3) Error: Java.lang.Error

Java.lang.Exception and Java.lang.Error inherit from Java.lang.Throwable;

Java.lang.RuntimeException inherits from Java.lang.Exception.

Compile-time Exception: The program is correct, but because the external environment conditions do not meet the trigger. For example: User error and I/O problem----program tries to open a remote socket port that does not exist. This is not a logic error for the program itself, but it is probably a remote machine name error (user spelling error). For commercial software systems, program developers must consider and address this issue. The Java compiler enforces the requirement to handle such exceptions, and if such exceptions are not caught, the program cannot be compiled.

Run-time exception: This means that there is a bug in the program, such as array out of bounds, 0 is removed, the entry parameter does not meet the specification ..... Such exceptions require a change of program to avoid, and the Java compiler enforces the requirement to handle such exceptions.

Error: Rarely seen, also difficult to solve through the program. It may originate from a bug in the program, but it is generally more likely to originate from environmental problems such as memory exhaustion. Errors do not need to be handled in the program, and there is a running environment to handle.

Java Exception &&runtimeexception exception

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.