Stacktrace of an Exception

Prints this throwable and its backtrace to the standard error stream. This method prints a stack trace for this Throwable object on the error output stream that is the value of the field System.err. The first line of output contains the result of the toString() method for this object. Remaining lines represent data previously recorded by the method fillInStackTrace(). The format of this information depends on the implementation.
In other words we say that printstacktrace will prints the current error and also the backtrace of the exception, from where it occurred. By using this we doesn’t require any message, handling etc. by ourself. This is a very handy tool in Debudding.


public class StackTraceExample {
	public static void main(String[] args) {
		}catch (Exception e) {
			e.printStackTrace(); // will print stacktrace

You may also like...