Java exception handling mechanism-simple comprehension

Source: Internet
Author: User

Description: (1) An exception is an unusual condition or error that occurs when a Java program runs (not compiled).

(2) Error indicates that the application itself is unable to overcome and restore a serious problem, the program is only a dead copy, for example, say memory overflow and thread deadlock and other system problems.

(3) Exception indicates that the program can also overcome and restore problems. Divided into common anomalies and system anomalies.

Common exception: also known as checked anomaly, is problems caused by changes or anomalies in the operating environment are issues that users can overcome. such as network drop line, hard disk space, and so on.

System exception: also known as unchecked exception, is the subclass of RuntimeException, is the software itself defects caused by the problem. which is the result of poorly thought out by software developers,

problem, software users cannot overcome and recover from this problem. but under this kind of problem can also let the software system continue to run or the person lets the software die.

such as: array out of bounds exception, null pointer exception, class conversion exception, etc.

(4) To solve the exception scheme:

1. Subject to compiler detection (checked), The compiler enforces a normal exception that must try: The catch or the throws declaration continues to be thrown to the upper calling method for processing.

2. the system exception can be handled or not handled by the virtual machine takeover, so the compiler does not enforce with try. catch processing or declaration with throws.

Java exception handling mechanism-simple comprehension

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.