java - Force an IllegalArgumentException -
one of past exam paper questions requires me modify method in such way illegalargumentexception occurs.
the method involves withdrawing money bank account balance
here method this.
public void withdraw( double ammount ) { this.balance -= ammount; }
how can modify method make exception occur? i've never seen exception before.
an exception can thrown throw
:
throw new illegalargumentexception("amount must positive.");
you should write rest of method yourself.
Comments
Post a Comment