?? inheritingexceptions.java
字號:
package chapter12;
/*
* 創(chuàng)建簡單的自定義異常。
*/
class SimpleException extends Exception{}
public class InheritingExceptions {
public void f() throws SimpleException{
System.out.println("Throw SimpleException from f()");
throw new SimpleException();
/*
* 拋出的是一個(gè)SimpleException的實(shí)例化對象
* 這個(gè)對象正好被catch,然后又執(zhí)行
* System.out.print("Caught it!");
*/
}
public static void main(String args[]){
InheritingExceptions sed=new InheritingExceptions();
try{
sed.f();
}catch(SimpleException e){
System.out.print("Caught it!");
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -