I have a class called Person. It has the following attributes; It has 2 attributes, ID, and Telephone. 1 person can have many
Person
attributes
ID
Telephone
//... Person foundPerson = null; for (Person p : personList){ if (p.getTelephone() == telephone){ foundPerson = p; //or simply return it from there break; } }
For implementing hashCode and equals you can observe this tutorial.
hashCode
equals