抛出异常的例子 public Rational divide (Rational r)throws Exception { if (r.numer ==0) { throw new Exception(denominator cannot be zero"); } long n numer*r.denom; long d denom*r.numer; return new Rational(n,d); ©2006计算机系杨厚群 All rights lefts reserved.©2006 计算机系 杨厚群 All rights & lefts reserved. 抛出异常的例子 public Rational divide(Rational r) throws Exception { if (r.numer == 0) { throw new Exception("denominator cannot be zero"); } long n = numer*r.denom; long d = denom*r.numer; return new Rational(n,d); }