I have this code:When you use exception.printStackTrace(), a complete chain of the names of the methods called, along with the line numbers, is printed from the point where the exception was thrown and up to the point where the exception was caught and printStackTrace() was called.
Code: Select all
package com.oracle.certification.enthuware.exceptions;
public class PrintingStackTest {
public static void main(String args[])
{
m1();
}
static void m1()
{
m2();
}
static void m2()
{
try
{
m3();
}
catch(Exception e)
{
e.printStackTrace();
}
}
static void m3() throws Exception
{
throw new Exception();
}
}
Code: Select all
java.lang.Exception
at com.oracle.certification.enthuware.exceptions.PrintingStackTest.m3(PrintingStackTest.java:27)
at com.oracle.certification.enthuware.exceptions.PrintingStackTest.m2(PrintingStackTest.java:17)
at com.oracle.certification.enthuware.exceptions.PrintingStackTest.m1(PrintingStackTest.java:11)
at com.oracle.certification.enthuware.exceptions.PrintingStackTest.main(PrintingStackTest.java:7)
Code: Select all
java.lang.Exception
at com.oracle.certification.enthuware.exceptions.PrintingStackTest.m3(PrintingStackTest.java:27)
at com.oracle.certification.enthuware.exceptions.PrintingStackTest.m2(PrintingStackTest.java:17)
at