Just a little smile ^ ^

yoyo_zeng

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

 

try {

// Code that might generate exceptions

  • }  catch(Type1 id1) {
    // Handle exceptions of Type1

  • }  catch(Type2 id2) {
    // Handle exceptions of Type2

  • }  catch(Type3 id3) {
    // Handle exceptions of Type3

    finally {

    // 每次都会发生的情况

     

    throws;后面跟随全部潜在的违例类型。方法定义可能抛出的异常:

    void f() throws tooBig, tooSmall, divZero { //... 

     

    抛出异常 throw:

    catch(Exception e) {
    System.out.println("一个违例已经产生");

    throw e;
    }

     

posted on 2012-11-16 09:56  yoyo_zeng  阅读(138)  评论(0编辑  收藏  举报