201671010138 2016-2017-2 "Java Programming" learning experience

Source: Internet
Author: User

after continuous learning and deepening of Java, we've got some basics of java. subsequently

This week studied the handling of anomalies. Exceptions in the program, which generally become out of the box, can be understood

is not normal, other programming languages also have such a situation, Java also exists inside

For such an architecture, we need to be clear that exceptions and errors are not a concept.

The Throw keyword always appears inside the function body to throw an exception, and the program will

The throw statement terminates execution immediately, which means the statement block after the throw statement does not execute

Once it throws an exception, the JVM will be in the catch corresponding to the try block containing it.

Throws the exception type match operation, if can match directly to be captured, once cannot match to continue

Throws the exception to the outer layer of the execution body.

The throws keyword always appears in the function header to indicate that the function might throw some kind of exception.

          Keyword collocation:try+catch / try+catch+finally/try+finally

There are several issues to be aware of in these three structures:

[1]try, catch, finally three block of statements can not be used alone, the three may be composed of Try+catch,

try+catch+finally,try+finally Three structures, catch statements can have one or more

, and all at the same peer, finally statement at most one.

[2]try, catch, finally three blocks of variables in the scope of the code block inside, that is, the variable is used for the OfficeThe scope of the part variable, independent and not accessible to each other separately. If you want to be accessible in three blocks, you need tovariables are defined outside of these blocks, which are declared outside of {}. [3] Multiple catch blocks will only match one of the exception classes and execute the CATCH block code without executing thecatch block, and the order in which the catch statements are matched is top to bottom, and the child classes need to be placed in front of the declaration processcapture.

201671010138 2016-2017-2 "Java Programming" learning experience

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.