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