?? chap7-3.txt
字號:
// 程序7-3
public class testFinally{
public static void main(String args[ ]) {
int a,b=0;
for(int i=0;i<3;i++){
System.out.println("Test No: "+(i+1));
try{
switch(i){
case 0: a=3/b; // 0作除數
break;
case 1: int c[ ]=new int[10];
c[10]=0; // 數組下標越界
break;
case 2: char ch="ABC".charAt(99); //字符串的下標越界
break;
case 3: return; // 通過return語句結束程序
}
}catch(ArithmeticException e) {
System.out.println("零作除數!");
}catch(ArrayIndexOutOfBoundsException e) {
System.out.println("數組下標越界!");
}catch(IndexOutOfBoundsException e) {
System.out.println("下標越界!");
}finally{
System.out.println("在finally塊中!");
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -