d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Java Question
Add Reply New Topic New Poll
Member
Posts: 31,293
Joined: Mar 25 2009
Gold: 0.00
Jun 8 2019 06:22pm
Code
public void withdraw(int amount) {
int withdrawal = -amount;
if(withdrawal < 0) {
transactions.add(withdrawal);
this.balance += withdrawal;
System.out.println(amount + " withdrawn. Balance is now " + this.balance);
} else {
System.out.println("Cannot Withdraw negative sums");
}
}




What does this part mean: int withdrawal = -amount;
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jun 9 2019 09:16am
-amount is the same as -1 * amount
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll