throw、 throws 想要自行丟出例外,可以使用" throw"天键 词,并生成指定的例外对象 try i double data =100/0.0; System.out. println("浮点数零除:"+data); if(string valueof (data).equals("Infinity)) throw new ArithmeticException("除零例外") catch(ArithmeticException e) System. out. println(e)throw、throws • 想要自行丢出例外,可以使用"throw"关键 词,并生成指定的例外对象 try { double data = 100 / 0.0; System.out.println("浮点数零除:" + data); if(String.valueOf(data).equals("Infinity")) throw new ArithmeticException("除零例外"); } catch(ArithmeticException e) { System.out.println(e); }