Java---Exception (exception)

Source: Internet
Author: User

Java exceptions are a mechanism provided by Java for handling errors.

The so-called error refers to some of the abnormal events that occur during the process of running the program (for example: except 0 overflow, array subscript out of bounds, the file to be read does not exist, etc.)

A well-designed program should provide a way to handle these errors when an exception occurs, so that the program does not block or produce unpredictable results because of an exception.

The Java program can generate an object of the exception class, which encapsulates some information about the exception event and submits it to the Java operating system, which is called throwing an exception, as an exception event occurs during execution.

When the Java system receives an exception object, it looks for the ability to handle this exception code and hand the current exception object to its processing, a process called catch (catch) exception.

Error is called a fault and is generated and thrown by a Java virtual machine, including dynamic link failure, virtual machine error, and the program does not handle it (nor can it handle it).

Exception: The parent class of all exceptions, whose subclasses correspond to a variety of possible exception events, typically require the user to display claims or captures.

RuntimeException: A special kind of anomaly, such as divisible by 0, array subscript out of bounds, and so on, it is more frequent, processing trouble, if the display declaration or capture will have a significant impact on the readability and operational efficiency of the program, Therefore, the system automatically detects it and gives it to the default exception handler (which the user does not have to handle).

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.