我试试
package ro.ex;
/**
* Created by roroco on 11/4/14.
*/
class Ex {
public void m() {
throw new Exception();
}
public void m2() {
throw new RuntimeException();
}
}
在 throw new Exception();
,intellij idea 引发“未处理的异常:java.lang.Exception”,但在 throw new RuntimeException();
中事实并非如此,我的问题是:是什么原因导致了这种差异?
最佳答案
查看此link关于检查和非检查异常
关于Java:为什么 "throw new Exception()"必须是 "add Exception to method signature",但 "throw new RuntimeException()"不是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26796864/