finally

Finally is so powerful that it will execute unconditionally no matter what goes wrong, whether it is caught or not. At the age of 24, I have only one requirement for a boyfriend, that is, finally.

usage

Finally is always used with a try. Even if there is no exception that must be caught, try{}finally{} is also recommended when there is something that must be executed unconditionally. Finally is executed even if a throwable fails to catch an error. Finally is executed even if there is a return code in the try.

Finally is a punching bag for someone who doesn’t fight back. It really can do, any time in a hurry to flow, I still wait for you. Finally can be the final destination.

case

Countdownlatch.countdown (), like countdownlatch in multithreading, should be executed in finally to prevent applications from getting stuck. The release of various resources, streams, must also be put finally for execution.

Talk about anomalies!

The parent class of exceptions is throwable, and its subclasses are Error,exception;

error

Such as: StackOverflowError

Exception

All other exceptions are checked.

This can be interpreted as an error and must be solved by the developer before it can be compiled. There are two ways to solve this problem: 1) throw to the upper layer; 2) try-catch processing.

RunTimeException: Not checked, not checked! Free from inspection!! No inspection!!

The important thing is to say three times, because it is not checked, there may be runtimeexceptions in your code. Java compilation checks do not tell you that there are runtimeexceptions, but they will show up when you actually run your code, such as classic 1/0, null Pointers, etc. If not, Java handles it.