Exception mechanisms in Java (compile-time exceptions)

Source: Internet
Author: User

/* 1 principle of the anomaly mechanism

* What is an exception : Another way of saying something wrong ;

* in java , There is a class that simulates all exceptions , and all exceptions must inherit from this class : Throwable;

 *  : Span style= "font-family: the song Body;" > When the program goes wrong ,JVM get error message Return to program call at . This is when our programmers write a program that provides a hint mechanism for certain high-risk operations We're suggesting this mechanism relative to the system is a trigger mechanism for handling exceptions

 *  One is what we see main () inside the function. There is also an invisible Span style= "font-family: the song Body;" > If the program normally finishes executing the program, exit

* All statements in the main () function Follow normal steps , then exit the virtual machine , which is the normal execution of a program . If main () When the statement in the method executes , it jumps to the error line and executes The code of the error mechanism. And then quit the program .

*

* 2 exception mechanism processing form

* the official so-called exception handling mechanism has two kinds :

* Try...catch ...: generally used in the client

* Throws: generally used on the class library side

* Throw: The beginning of the exception prompt

Exception mechanisms in Java (compile-time 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.