The use try catch

In the ideal Shortcut ctrl + alt + T;

 

catch (Exception E) {
e.printStackTrace ();
}
exception occurs when a try statement, the statement is executed in the catch, java runtime system will automatically initialize E Exception catch brackets, i.e. instantiated Exception Type Object. e is this object reference name. Then e (reference) will automatically call the specified method Exception class, also appeared e.printStackTrace ();.
It means printStackTrace () method is: the print line position and the error cause of the abnormality information in the program in the command. (This is the vernacular to explain, easier to understand)

After capturing the exception, if the corresponding error message is output, respectively, in FIG.

 

 

try catch finally

try in error, it will be executed inside the catch, catch the error which can capture information such as; will finally executed inside;

Guess you like

Origin www.cnblogs.com/cherishforchen/p/11330552.html