... has not occurred, you can see the stack trace any time by calling Thread.dumpStack()
.
Stack Trace for an ArithmeticException
The first line specifies that an ArithmeticException
has occurred. The text after the name of the exception (“/ by zero
”) indicates that this exception occurred as a result of an attempt to divide by zero. Java does not allow division by zero in integer arithmetic. When this occurs, Java throws an ArithmeticException
. ArithmeticException
s can arise from a number of different problems, so the extra data (“/ by zero
”) provides more specific information.
Starting from the last line of the stack trace, we see that the exception was detected in line 19 of method main
. Each line of the stack trace contains the class name and ...
Get Java How To Program, Late Objects, 11th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.