聲明(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