public class ThrowOut {
  public static void
  main(String[] args) throws Throwable {
    try {
      throw new Throwable();
    } catch(Exception e) {
      System.err.println("Caught in main()");
    }
  }
} ///:~
这个错在哪里? 说明下原因,谢谢。

解决方案 »

  1.   

    new Throwable();//接口能new吗?
      

  2.   

    Exception是Throwable的子类,所以抛出的Throwable异常不能被捕获。
      

  3.   

    throw new Exception("My Exception Message");
    是非常常见的做法。接口不能new
      

  4.   

    java.lang 
    类 Throwable
    java.lang.Object
      java.lang.Throwable
    所有已实现的接口: 
    Serializable 
    直接已知子类: 
    Error, Exception 这个不是借口好不?
      

  5.   

    重新抛出的异常不会被同一个try块的其他catch块处理,只能被包裹当前try…catch结构的更大的try…catch结构捕获处理,或者被抛出当前方法,由方法的调用者来进行处理