I have created a model
public class Portfolio {
private String id;
private String name;
public Portfolio() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
i have a list of this model. i want to find a position of an specific item in it.
I have tried
Portfolio p = new Portfolio();
p.setId("1");
p.setName("Test");
int i = PortfolioList.indexOf(p);
when i log the value of "i" it returns "-1". but i m sure the "p" object is available in arraylist.
i dont want to use for() loop. i think it takes time to find an object, if there is so many objects in our arraylist.
what is the currect way of using indexOf() method?
PortfolioList? That might be useful in answering the question.