I'm trying to modify my list by updating it and finding the last name. How can I rewrite my last 2 methods to do that.
import java.util.ArrayList;
public class DataCollection {
ArrayList<Person> list = new ArrayList<>();
Person newName = new Person(10,"aas","gym","798",876-123);
Person p1 = new Person(11,"aaa", "gina","654",911-911);
Person p2 = new Person(12, "persia","weee","546",324);
public void add(Person person) {
list.add(person);
}
public int remove(String lastName) {
for (int i = 0; i < list.size(); i++) {
Person person = list.get(i);
if (person.getLastName().equals(lastName)) {
list.remove(person);
}
}
public int update(String lastName, String newName){
Person person;
for (int i = 0; i < list.size(); i++) {
person = list.get(i);
if (person.lastName != person.){
Person.setLastName(newName);
}
public Person find (String lastName){
Person person;
for (int i = 0; i < list.size(); i++) {
person = list.get(i);
if (person.lastName.equals(lastName)) {
System.out.print(lastName);
}
}
}
}
}
}
}