诡异的finally
碰到这样一个程序:package com.whpu.test.w716;import
import
import
public class FinallyDemo {
public String getValue(){
String msg = "ok";
try {
FileInputStream fin = new FileInputStream("d:/a.txt");//有a.txt此此文件
fin.read();
return msg;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
msg = "finally";
System.out.println("我被调用");
}
return msg;
}
public static void main(String[] args) {
FinallyDemo f = new FinallyDemo();
System.out.println(f.getValue());
}
}
输出结果为:
我被调用
ok
//本人不解,请大虾解释下