Exception Handling Question

后端 未结 8 669
谎友^
谎友^ 2020-12-13 02:30

I have a question regarding exception handling. Consider following Java code snippet.

        try{
            //code
        }catch(SubSubException subsube         


        
8条回答
  •  不思量自难忘°
    2020-12-13 02:49

    I think, better (much readable):

     try {    
       .....
     } 
     catch (IndexOutOfBoundsException iooe) {    } 
     catch (ArrayIndexOutOfBoundsException aiooe) {    }
     .....
    

    and

      try {
         .....
      } 
      catch (Exception e) {
         if (e instanceof Exception) {        } else 
         if (e instanceof Exception) {        } else
         .....
      }
    

提交回复
热议问题