6.9 try...catch語句
一個try-catch語句應該具有如下格式:
try {
statements;
} catch (ExceptionClass e) {
statements;
}
一個try-catch語句後面也可能跟著一個finally語句,不論try代碼塊是否順利執行完,它都會被執行。
try {
statements;
} catch (ExceptionClass e) {
statements;
} finally {
statements;
}