【发布时间】:2012-07-23 17:54:21
【问题描述】:
当方法抛出和异常时,我们是否需要在方法内部有一个 try 块?
例如,
public void foo() throws SomeException{
try{
// content of method
}
}
是否需要 try 块?或者,该方法是否能够在没有它的情况下抛出 SomeException :
public void foo() throws SomeException{
// content of method
}
当我们不使用 throw 显式抛出 SomeException 时就是这种情况。
【问题讨论】:
标签: java exception try-catch throw throws