Java Exception Using PrintStacktrace()
Chapter:
Exception Handling
Last Updated:
05-11-2016 14:15:40 UTC
Program:
/* ............... START ............... */
public class JavaExceptionUsingPrintStacktrace {
public static void main(String[] args) {
try {
int a[] = new int[1];
a[1] = 12;
} catch (Exception e) {
e.printStackTrace();
}
}
}
/* ............... END ............... */
Output
java.lang.ArrayIndexOutOfBoundsException: 1
at ExceptionHandling.JavaExceptionUsingPrintStacktrace.main(JavaExceptionUsingPrintStacktrace.java:9)
Notes:
-
The java.lang.Throwable.printStackTrace() method prints this throwable and its backtrace to the standard error stream. It prints a stack trace for this Throwable object on the error output stream that is the value of the field System.err.
Tags
Exception Using PrintStacktrace() , Java, Exception Handling