I have a Personnel class, where I store all of Objects of type student, professor, tutor...
class Personnel {
ArrayList<Student> activeStudentsList = new ArrayList<Student>();
}
and I have a class Student
class Student extends Person {
public Student (String studentID, String firstName, String lastName) {
super(firstName, lastName);
this.studentID = studentID;
}
}
Now, what I want to do before adding a student into array list, is to check if he's already there. I was using this:
private boolean isStudentActive(String studentID) {
if (activeStudentsList.contains(studentID)) {
System.out.println("The student " + studentID + " is already on the list.");
return true;
} else
return false;
}
The problem is, my array list is ArrayList<Student>, so I can't search for a specific String (studentID). How do I do this? How do I only search String studentID of each object on the list?
EDIT: (Is there somethin like activeStudentsList.studentID.contains(studentID) ?)