, . , , . , , , ID . equals + hashcode. , , ( , ). , :
list.contains(Student);
, , - :
matchedStudents = new ArrayList<Student>();
for(Student currentStudent : studentList)
{
if(currentStudent.getName().equalsIgnoreCase(searchString)
{
matchedStudents.add(currentStudent);
}
}
return matchedStudents;
GPA , , , GPA == searchCriteria.
that, as said, it should be possible to write such a function:
function searchStudent(String searchString, String type)
{
switch(type)
{
case gpa:
case id:
case name:
}
}
which should run you.
source
share