public class AccountManager {
priavte Map accountTotals = new HashMap();
private int retirementFund;
public int getbalance(String accountName) {
**Integer Total = (Integer) accountTotals.get(accountName);
if(total == Null)
total = Integer.valueof(0);
return total.intValue;**
}
public void setBalance (string accountName, int amount) {
accountTotals.put(accountname, Integer.valueof(amount));
}
}
I can replace the highlighted code with two of the them to perform it:
1:
int Total = accountTotals.get(accountName);
if(total == null)
total = 0;
return total;
2:
Integer total = accountTotals.get(accountName);
if(total == null)
total = 0;
return total;
3:
return accountTotals.get(accountName);
Can someone tell me which two of the above 3 I should replace with the highlighted code ? And why ?
Thanks!!