I have an ArrayList of custom objects I called Questions. These Questions contain the question, a unique ID, and an ArrayList of Answers. Now I'm trying to search for the question with a specific unique ID. This is what I'm currently doing but I'm worried this might take too long for a big list, so I was wondering if there was a faster way to do this.
public Question getQuestion(String idLookingFor) {
for (Question question : questions) {
if (question.getId().equals(idLookingFor))
return question;
}
return null;
}