Probably a newbie question, but everyone seems to use e.printStackTrace(), but I have always used System.out.println(e) when exception handling. What is the difference and why is e.printStackTrace() preferable?
Probably a newbie question, but everyone seems to use e.printStackTrace() , but I have
Share
The output stream used is not the same as pointed out by @Brian, but the level of detail is not the same either – you can try with the simple test below. Output:
With
println: you only know what exception has been thrownWith
printStackTrace: you also know what caused it (line numbers + call stack)