首页 > 其他 > 详细

1. 编写一个类ExceptionTest,在main方法中使用try-catch-finally语句结构实现:

时间:2019-05-08 18:12:15      阅读:623      评论:0      收藏:0      [点我收藏+]
package bbb;

import java.util.Scanner;

public class aaa {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入除数:");
        int op1 = input.nextInt();
        System.out.println("请输入被除数:");
        int op2 = input.nextInt();
        int result = 0;
        try {
            result = op1 / op2;
        } catch (ArithmeticException e) {
            e.printStackTrace();
        } finally {
            System.out.println("异常处理");
        }
        System.out.println(result);
    }
}

 

1. 编写一个类ExceptionTest,在main方法中使用try-catch-finally语句结构实现:

原文:https://www.cnblogs.com/cvfe/p/10832460.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!