public static void main(String args[]) {
int i = 0; String greetings[] = { " Hello world !", " Hello World !! ", " HELLO WORLD !!!" }; while (i < 4) { try { System.out.println(greetings[i++]); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("數組下標越界異常"); } finally { System.out.println(i); } } }
輸出結果為:
Hello world !1 Hello World !! 2 HELLO WORLD !!!3數組下標越界異常4
添加回答
舉報
0/150
提交
取消