I'm wanting to be able to return the position of an object using the indexOf method, but only want to pass the name of the contact to search for this, is there any way for this to be done?
I currently have this method:
private static ArrayList<Contacts> contactList = new ArrayList<Contacts>();
public class Contacts {
private String name;
private String number;
public Contacts(String name, String number) {
this.name = name;
this.number = number;
}
public String getName() {
return name;
}
public String getNumber() {
return number;
}
public void setName(String name) {
this.name = name;
}
public void setNumber(String number) {
this.number = number;
}
public int findItem(String name) {
return contactList.indexOf(name);
}