Each
line in the stack trace represents Stack Trace Element.
class StackTraceElement{ void divide(){ int var1 = 10/0; } void show(){ divide(); } void print(){ show(); } public static void main(String args[]){ StackTraceElement obj = new StackTraceElement(); obj.print(); } }
When
you run the above program, it generates “ArithmeticException” and
JVM throws the stack trace like below.
Exception in thread "main" java.lang.ArithmeticException: / by zero at StackTraceElement.divide(StackTraceElement.java:4) at StackTraceElement.show(StackTraceElement.java:8) at StackTraceElement.print(StackTraceElement.java:12) at StackTraceElement.main(StackTraceElement.java:17)
Each
line in the stack trace represents Stack Trace Element.
For
Ex:
"StackTraceElement.divide(StackTraceElement.java:4)" is a Stack Trace Element.
No comments:
Post a Comment