声明(Unchecked Exception)沿着方法签名b/c抛出异常的好处是什么?它不强制调用者保留在try catch块中。Java抛出RuntimeException的好处
public void testRuntimeEx()throws RuntimeException{
if(1==1){throw new RuntimeException()}
}
//Caller method
public void testCaller(){
// not necessery to handle even caller does not known which RuntimeException might be throws then what is the benefit throws clause with method signature
testRuntimeEx();
}
您不必声明它,因为它没有被选中。 – edwardw