Online Java Compiler By
JavaTpoint.com
public class ThrowablePrintStackTraceExample2 { public static void main(String[] args)throws Throwable { try{ exceptionTest(); }catch(Throwable t){ t.printStackTrace(); } } public static void exceptionTest() throws Exception{ System.out.println("Inside exceptionTest() method"); throw new Exception("Throwing localized message!"); } }
Output