Exceptions and logs thrown in Java (1)

Source: Internet
Author: User

Through their own understanding of the study, there will certainly be mistakes, I hope that we help correct, utilitarian and violent wording ...

Try

Where if is to determine if you have defined the exception, throw is to throw the exception, below you see my definition of the exception class, Notfoundname accept the string, usually I write the name of the exception

This is the exception class that I define, except that the constructor is basically auto-generated. Catch is the exception and deal with it.

Guys[0].addmane I wrote above, I called the method of adding a name to handle the exception, while some people will write finally

The purpose of the finally statement is to be afraid of modifying the mutable variable in the exception's throw, so use finally to change the content back

When a catch statement does not exist, the finally statement must be present and immediately after the try statement.
? No statements can exist between the try statement and the catch statement, nor can any statements be present in the catch and finally statements, where the statement does not include the comment statement.
? When a catch statement does not exist, the finally statement must be present and immediately after the try statement. No statements can exist between a try statement and a catch statement.

Exceptions and logs thrown in Java (1)

Related Article

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.