第四次Java作业

package hh;

import java.util.Scanner;

public class ExceptionTest {

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        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);

    }

}

  这次简单一点

猜你喜欢

转载自www.cnblogs.com/2300524355a/p/10883637.html