注意:在finally中通常不写return,因为finally是必须会执行的,会将上面代码的返回值覆盖
/**
*
* 演示finall的注意点
*/
package Test15_Demo.Demo09;/*
@create 2020--12--03--15:23
*/
import java.io.FileWriter;
import java.io.IOException;
public class FinallyTest {
public static void main(String[] args) {
try {
System.out.println(10 / 0);
FileWriter fw = new FileWriter("");
} catch (ArithmeticException ae) {
} catch (IOException ie) {
}finally {
//注意:在finally中通常不写return,因为finally是必须会执行的,会将上面代码的返回值覆盖
//return;
}
}
}