📄 try_catch_finally.java
字号:
public class try_catch_finally{
public static void main (String args[]) {
int i = 0;
String greetings [] = {
"1 Hello world!",
"2 No, I mean it!",
"3 HELLO WORLD!!"
};
while (i < 4) {
try {
System.out.println (greetings[i]);
} catch (ArrayIndexOutOfBoundsException e){
System.out.println( "数组下标越界");
} finally {
System.out.println("This is always printed");
}
i++;
} // end while()
} // end main()
}
/* 当循环被执行时,下述在屏幕上出现的信息将改变。
1 Hello world!
This is always printed
2 No, I mean it!
This is always printed
3 HELLO WORLD!!
This is always printed
数组下标越界
This is always printed */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -