[英]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.