e.printStackTrace ();

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 the name of this object reference. 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 explanation easier to understand)

on System.out.println (e) and e.printStackTrace ()

in the case of throwing an exception, there are many methods, System.out.println (e); print out this method abnormal, and outputs an exception where there is; e.printStackTrace () also prints the exception, but it will also show a deeper call information. For example:

A the extends ---> --- the extends B> C

when problems arise during the creation of the A's, we throw an exception. <

System.out.println (E), in addition to the standard exception, only print at A and then output outward layers.

e.printStackTrace (), in addition to the standard exception, print

 AT C

 AT B

 AT A

 ....... again outer investigation.

In the case of the investigation to the outer layer, they are the same. Finally, we will return com.sun.midp.main.Main.main

 

System.out.println (); display when an exception occurs when you set a string of information; IO operations carried out on such as the following code, try it, you know you want to throw an exception and certainly IO exception, catch inside and wrote, specific IOException, print their own on the line

the try {
// function
}
the catch (IOException EXC) {
    System.out.println ( "IOException");
}
e.printStackTrace (); print is abnormal stack information indicating the cause of the error, in fact, when an exception occurs, usually to handle exceptions, this is a good programming habits, so e.printStackTrace () can easily debug your program!

Guess you like

Origin www.cnblogs.com/022414ls/p/11610487.html