Current location - Quotes Website - Collection of slogans - What do Java: try {} and catch{} mean?
What do Java: try {} and catch{} mean?
Try {

The statement surrounded by try is that the java compiler thinks there may be an exception, so you can handle it in advance. Catch{} is to catch the exception in the above statement, and then write a method to handle this exception in catch!

Try {

Sleep (1000);

Sleep (1000); When this method is executed, it may throw a blocking exception in catch. If it does happen, then catch will catch this exception and let him return. If no exception is caught, the program will continue to go down!