开发者

If a method can throw multiple exceptions, how to declare it?

I think throws Exception only handles the general case.

If my method 开发者_运维问答can throw multiple exceptions, how to declare it?


public writeThisToFile(String line) throws FileNotFoundException, AppSpecificServiceException, SecurityException{
 /* some thing */
}

See Also

  • § 8.4.6 Method Throws


public void yourMethod() throws anException, anotherException {
 //stuff here
}


Using the throws clause:

public void myMethod()
    throws Exception1, Exception2
{
    ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜