?? testthrowsexception.java
字號:
class MyException extends Exception {
String NewExceptionObject;
public MyException() {
this.NewExceptionObject="";
}
public MyException(String s) {
this.NewExceptionObject=s;
}
String ShowExceptionInfo() {
return this.NewExceptionObject;
}
}
public class TestThrowsException {
public static void main(String args[]) {
try {
Test();
}
catch(MyException e) {
System.out.println("MyException類:");
System.out.println("已經捕捉到拋出的異常對象!");
System.out.println("異常信息:"+e.ShowExceptionInfo());
}
}
static void Test() throws MyException {
throw new MyException("方法自身產生的異常將由調用者處理!");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -