Java异常的几种处理方式

Java的异常处理机制包含4,5中处理方式,今天我们来谈谈这几种方式的实现:

1)try...catch...分为单catch与多catch处理方式,其本质执行方法基本相同:

2)try...catch...finally:

3)自动关闭资源的try语句:

4)嵌套的try...catch语句:

5)多异常捕获:

catch (IOException ex) {

     logger.log(ex);

    throw ex;

catch (SQLException ex) {

     logger.log(ex);

     throw ex;

}

猜你喜欢

转载自blog.csdn.net/weixin_42218884/article/details/82154618