.throw new Exception("a");
"a"他就是一个提示信息,你可以在里面输入提示,如果出现异常,他就会打印出来
- @Test
 
-     public void testException() {
 
-         try {
 
-             throw new Exception("a");
 
-         } catch (Exception e) {
 
-             e.printStackTrace();
 
-         }
 
-     }
输出:
- java.lang.Exception: a
 
-         at com.atguigu.vodtest.TestVod.testException(TestVod.java:43)
 
-         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 
-         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 
-         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 
-         ..................
 
-         at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)