?? exceptiondemo.java
字號:
public class ExceptionDemo
{
public static void main (String args[])
{
int i=0;
int a[] = {5,6,7,8};
for(i=0;i<5;i++)
{
try
{
System.out.println("a["+i+"]/"+i+"="+(a[i]/i));
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("捕獲數組下標越界異常!");
}
catch(ArithmeticException e)
{
System.out.println("捕獲算術異常!");
}
catch(Exception e)
{
System.out.println("捕獲"+e.getMessage()+"異常!");
} //顯示異常信息
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -