JAVA basics (⑦ abnormal)

1 exception is not an error.

2 During program execution, any abnormal condition that interrupts the normal program flow is an error or exception.

3 Exceptions can usually be caught or thrown.

4 keywords for exception handling (try catch final throw throws).

5 The try catch in the exception can be nested with each other,

6 In either case, the exception should eventually be caught and dealt with accordingly. The advantage of using the exception class is that it provides great convenience for program debugging, and can ensure that the program can continue to execute in the event of an exception, thereby improving the robustness of the program.

7 Usually when catch catches an exception, use (Exception) at the end to ensure that the exception can be caught.

8 Common exceptions are: NullPointerException Null pointer exception. ArrayIndexOutOfBoundsException Index out of bounds exception. ClassCassException Type conversion exception.

おすすめ

転載: blog.csdn.net/weixin_54255580/article/details/121938262