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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -