Chapter 5 Abnormalities

Definition of exception: An exception refers to an abnormal event that occurs during the running of a program, which will interrupt the running program. .

Java's exception handling is implemented through five keywords: try, catch, finally, throw and throws..

Example: Add a finally block after the try-catch-finally block, put the statement in the finally block. The finally code can be executed whether or not an exception occurs.

Common exception types:

Multiple catch blocks:

The difference from Exception is that it can be caught completely separately and uses multiple catch blocks.

After executing one of the catch statements, all subsequent catch statements will be ignored.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326288932&siteId=291194637