?? 7.11throwexception.java
字號:
public class ThrowException{
public static int a=0;
public static void main(String []args){
try{
if (a == 0)
throw new ArithmeticException("Divided by zero!"); //拋出被零除的異常
System.out.println(8/a);
}
catch(ArithmeticException e){ //捕獲被零除的異常
System.err.println("An arithmetic exception is thrown!");
System.err.println("Information:"+e.toString());
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -