黑马程序员技术交流社区

标题: FinallyTest的使用方法 [打印本页]

作者: 徐方锐    时间: 2016-5-30 23:26
标题: FinallyTest的使用方法
public class FinallyTest {
        public static void main(String[] args) {
               
                int x = 20;
                try{
                        x = 10;
                        System.out.println(x/0);
                } catch (ArithmeticException e) {
                        System.out.println("除数不能为零");
                        x = 5;
                } finally {
                        x = 3;
                        System.out.println("除法运算结束");
                }
               
                System.out.println("over");
                System.out.println("x=" + x);
               
        }
}




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2