标签:
*
1,
public void methodA(){ //InputStream ioInputStream= new FileInputStream(file); methodB();//出错,需要throws或try/catch } public void methodB() throws IOException { int a=0; if(10/a==1){ throw new ArithmeticException();//不出错 }else{ throw new IOException();//出错,需要throws或try/catch } }
总结:如果throw的是Exception的子类下需要处理的那一支(即不是RuntimeException那一支),则需要throws或try/catch
*
标签:
原文地址:http://www.cnblogs.com/qingmaple/p/4926002.html