import java.io.IOException;
public class finallytest {
public void test(int n) throws IOException{
try {
n=n+10;
if(n>100){
throw new IOException("n>100");
}
if(n>10){
test(n);
}
}finally{
System.out.println("finally:" + n);
}
}
public static void main(String[] args) {
finallytest f = new finallytest();
try {
f.test(1);
System.out.print("ok!");
} catch (IOException e) {
System.out.println("ccc"+e.getMessage());
}
}
}
finally块会在try执行完后马上执行