黑马程序员技术交流社区

标题: IO流的 有点搞不清楚 [打印本页]

作者: GAREN    时间: 2016-5-31 18:06
标题: IO流的 有点搞不清楚
import java.io.*;
public class Mine {
    public static void main(String argv[]){
         Mine m=new Mine();
         System.out.println(m.amethod());
    }
    public int amethod() {
         try {
             FileInputStream dis=
new FileInputStream("Hello.txt");
         }catch (FileNotFoundException fne) {
             System.out.println("No such file found");
             return -1;
         }catch(IOException ioe) {
         } finally{
             System.out.println("Doing finally");
         }
         return 0;
    }
}
A. No such file found
B. No such file found ,-1
C. No such file found, Doing finally, -1
D. 0

作者: zhanghongtuo    时间: 2016-5-31 18:15
我认为选C
先抛出异常,执行到return之前,再执行finally,再返回catch中的return
作者: GAREN    时间: 2016-6-2 00:51
zhanghongtuo 发表于 2016-5-31 18:15
我认为选C
先抛出异常,执行到return之前,再执行finally,再返回catch中的return

多谢啊{:2_30:}{:2{:2_36:}




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2