Abh*_*ini 2 java exception-handling
但是在下面的程序中,当在catch语句中重新抛出异常时,没有throws子句,没有错误吗?怎么样?
Class Throwdemo {
static void demoproc(){
try{
throw new NullPoinerException ("demo");
}catch(NullPointerException e) {
System.out.println("Caught inside demoproc.");
throw e;
}
}
public static void main(String Args[]){
try[
demoproc();
}catch(NullPointerException e) {
System.out.println("Recaught : " + e);
}
}
}
Run Code Online (Sandbox Code Playgroud)
输出是
Caught inside demoproc.
Recaught : java.lang.NullPointerException: demo
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
150 次 |
| 最近记录: |