[英]If a method can throw multiple exceptions, how to declare it?
我认为throws Exception
只能处理一般情况。
如果我的方法可以抛出多个异常,如何声明?
public writeThisToFile(String line) throws FileNotFoundException, AppSpecificServiceException, SecurityException{
/* some thing */
}
也可以看看
public void yourMethod() throws anException, anotherException {
//stuff here
}
使用throws
子句:
public void myMethod()
throws Exception1, Exception2
{
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.