?? demonexception.java
字號:
//使用自定義異常類。
class MyException extends Exception {
private int attribute;
MyException(int i) {
attribute = i;
}
public String toString() {
return "MyException[" + attribute + "]";
}
}
class DemonException {
static void compare(int a) throws MyException {
System.out.println("Called compare(" + a + ")");
if(a > 5)
throw new MyException(a);
System.out.println("Normal exit");
}
public static void main(String args[]) {
try {
compare(3);
compare(15);
}
catch (MyException e) {
System.out.println("Caught " + e);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -