在有finally语句中,其他位置有 return语句也要先执行finally
public class TestFinally {
public static void main(String[] args) {
int i = method1();
System.out.println(i);
}
public static int method1() {
try {
System.out.println(10 / 0);
return 1;
}catch(Exception e) {
e.printStackTrace();
}finally {
System.out.println("卢本伟没哟开挂");
return 2;
}
}
}