Java Questions! About List and Objects

Something like this.

double increase = 10000;

for (Employee employee : theList) {
    double salaryNow = employee.getSalary();
    employee.setSalary(salaryNow + increase);
}

Caution – you should never use a double to store an amount of money, as you will be subject to floating point rounding errors. Please use a BigDecimal instead. I’ve only done it in this snippet here to match what you have in your Employee class.

Leave a Comment