异常处理信息

 

public class Test { public static void main(String[] args) { try { test1(); } catch(Exception e ) { e.printStackTrace(); System.out.println(e.getMessage()); } } public static void test() throws Exception { String a = ""; String b = null; try { System.out.println(b.toString()); } catch(Exception e) { e.printStackTrace(); throw new Exception("this is a message for u 2 show" ,e); } } public static void test1() throws Exception { test(); } }

 

this is a message for u 2 show java.lang.NullPointerException at Test.test(Test.java:18) at Test.test1(Test.java:26) at Test.main(Test.java:7) java.lang.Exception: this is a message for u 2 show at Test.test(Test.java:21) at Test.test1(Test.java:26) at Test.main(Test.java:7) Caused by: java.lang.NullPointerException at Test.test(Test.java:18) ... 2 more

你可能感兴趣的:(exception,String,Class)