
package jdk.base;
/**
* @author <a href="mailto:czy88840616@gmail.com">czy</a>
* @since 2010-3-23 22:37:28
*/
public class FinallyDemo {
public static void main(String[] args) {
System.out.println("------------");
System.out.println(test());
System.out.println("------------");
}
public static boolean test() {
try {
throw new Exception("test finally");
} catch (Exception e) {
System.out.println("in catch");
return true;
}finally {
System.out.println("in finally");
}
}
}
输出:
------------
in catch
in finally
true
------------
结论:return在finally后执行……