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