James Bell James Bell - 5 months ago 7
Java Question

Not Able to Catch Exception

I am writing some code in the Java like this:

System.out.println("Here Checkpoint 15");
try {

//Code Executable

} catch (Exception e) {
e.printStackTrace();
}

System.out.println("Here Checkpoint 16");


But in output I got only:

Here Checkpoint 15


And no exception stack trace.

What would be wrong in it?

Answer

Its not all about Exception some times there is Error

To Check it and make code working catch Error

like this

System.out.println("Here Checkpoint 15");
try {

//Code Executable

} catch (Error e) {
   e.printStackTrace();
}

System.out.println("Here Checkpoint 16");