1. 程式人生 > >java中try,catch,finally的合理應用

java中try,catch,finally的合理應用

  1. try {
  2. try {
  3.         code that might throw exceptions
  4.     } finally {
  5.         code that might throw exceptions
  6.     }
  7. catch (Exception e) {
  8.     show error dialog
  9. }
finally中將處理try中出錯後的一些事情(如sql出錯後,關閉資料庫連線),而catch中將處理try和finally中的異常