📄 invtarexctest.java
字号:
import java.lang.reflect.*;public class InvTarExcTest{ public static void f() throws Exception { throw new Exception("throwing inner exception"); } public static void main(String av[]) { try { Class c = Class.forName("InvTarExcTest"); Method m = c.getMethod("f", new Class[0]); m.invoke(null, null); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); System.out.println("Caught itexception: " + e.getMessage()); // e.printStackTrace(System.out); System.out.println("Target is: " + t.getMessage()); // t.printStackTrace(System.out); } catch (Throwable t) { System.out.println("Caught throwable: " + t); t.printStackTrace(System.out); System.out.println("This should not happen."); } }}/* Expected Output:Caught itexception: nullTarget is: throwing inner exception*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -