Java / Exception
What is rethrowing an exception?
Exceptions that raised in the try block are handled in the catch block. If it is unable to handle that exception, it can re-throw that exception using throw keyword. It is called re-throwing an exception.
try { String s = null; System.out.println(s.equals(hello)); //This statement throws NullPointerException } catch (NullPointerException ex) { System.out.println("NullPointerException is caught."); throw ex; //Re-throwing NullPointerException }
More Related questions...