package com.liu.exception; import com.liu.oop.demo2.A; public class Test1 { public static void main(String[] args) { try { new Test1().test(1,0); } catch (ArithmeticException e) { e.printStackTrace(); } finally { } } //假设这个方法中 处理不了这个异常 方法上抛出异常 public void test(int a ,int b) throws ArithmeticException { if (b==0){ throw new ArithmeticException();//主动抛出异常,一般在方法中使用 } } }