为什么要return exception呢?你throw exception不就可以了吗?

解决方案 »

  1.   


    exception是用来抛的,不是用来返回的。
      

  2.   

    我是在MyNote上看到一句话说a method can return an exception.但我不知道怎么写,所以来问问
      

  3.   

    当然可以:public class ExceptionTest
    {
    public static void main(String[] args)
    {
    System.out.println(amethod().getMessage());
    }

    static Exception amethod()
    {
    return new Exception("an Exception");
    }
    }输出:an Exception