?? demonfinally.java
字號:
// 使用finally。
//演示finally的用法。
class DemonFinally {
// Through an exception out of the method.
static void methodA() {
try {
System.out.println("inside methodA");
throw new RuntimeException("demonstration");
}
finally {
System.out.println("methodA's finally");
}
}
// Return from within a try block.
static void methodB() {
try {
System.out.println("inside methodB");
return;
}
finally {
System.out.println("methodB's finally");
}
}
// Execute a try block normally.
static void methodC() {
try {
System.out.println("inside methodC");
}
finally {
System.out.println("methodC's finally");
}
}
public static void main(String args[]) {
try {
methodA();
}
catch (Exception e) {
System.out.println("Exception caught");
}
methodB();
methodC();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -