黑马程序员技术交流社区

标题: FinallyTest [打印本页]

作者: shilu    时间: 2015-10-15 16: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