public class q {
public static void main(String[] args) {
Try t=new Try();
t.foo();
}
}
class Try
{
public static void foo() {
try {
System.out.println("try");
}
finally {
System.out.println("finally");
foo();
}
}
}楼主说的不全对,运行后是先finally后try,但是是死循环的,不断输出finally和try,运行着就停掉了,这种死循环的做法是不对的,个人认为这个死循环结果没什么参考意义。把红色的foo()注释掉,运行结果是try,finally; |