自定义异常类:
public class InsufficientFundsException extends Exception { public InsufficientFundsException(String message) { super(message); } }
使用自定义异常:
public void withdraw(double amount) throws InsufficientFundsException { if (balance < amount) { throw new InsufficientFundsExcepti