Java exception Mechanism

Source: Internet
Author: User

Java exception Mechanism

1. What is an exception?

Exception: an event that interrupts the normal instruction stream (the issue caused by the program at runtime is irrelevant to the compilation)

2. Exception Classification


These classes are provided by JDK.


Exception is divided into two categories:

Uncheck exception (such as RuntimeException)

Check exception

Thriwable can be divided into two types:

Error)


3. How to Use the try... catch... finally structure


Try {

Code with exceptions

}

Catch (Exception e ){

E. printStackTrace ();

}

Finally {// Execute

System. out. print (1 );

}

Summary:

1. programmers can't do anything about Error. They can only handle Exception.

2. Handling exceptions is related to the robustness of the system.

3. Use try... catch... finally to handle code that may encounter 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.