public static void main(String args[]) throws Exception{
    try{
        int i = 5/0;
    }catch(InterruptedException e){
        System.out.print("ie ");
    }catch(RuntimeException e){
        System.out.print("re ");
    }
}请问以上代码,为什么编译的时候不过呢InterruptedException 到底是个怎样的东西啊

解决方案 »

  1.   


     try{
            int i = 5/0;
        }
        catch(RuntimeException e){
            System.out.print("re ");
        }这样 就可以,你那个异常 线程处理时候 比较多,你这个不会,
      

  2.   


    我当然知道这个可以了我想问的是为什么加了
    catch(InterruptedException e)
    编译不能通过也就是我想知道InterruptedException 异常类怎么用阿
      

  3.   


    原因是:
    Unreachable catch block for InterruptedException. This exception is never thrown from the try statement body
      

  4.   

    楼上的回答貌似是把代码考上去后的编译结果阿
    呵呵
    还是谢谢了
    现在明白了
    只有在try代码块中有可能抛出的异常才能在catch中捕捉
    否则编译不能通过