Need to use a for-each loop and the raise each person gets is 1000.
Would it be like this?
int raise = 1000;
for (Person i : people){
people.add(raise, i);
}
im working with this
public ArrayList<Person> people;
If what you want is to raise for example salary by 1000 for every person, it would be more like:
1.Define a class.
public class Person {
private int salary;
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
public void raiseSalary(int salary) {
this.salary += salary;
}
}
2.Use raiseSalary(int salary) method on every Person in your for-each loop.
List<Person> people = new ArrayList<Person>();
people.add(new Person());
for (Person person : people) {
person.raiseSalary(1000);
}
Dont forget to import java.util.* in order to use List and ArrayList.
Read about for-each loop here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With