I was more after the code around what you have here.
How are you obtaining the student instance which you are passing in to this method?
Do you have a get method on this class which does :
somewhere in it? like:
public Student findWithName(String name) {
Student student = null;
Iterator<Student> iterator = students.iterator();
while(null == student && iterator.hasNext()) {
Student potential = iterator.next();
if(potential.getName.equalsIgnoreCase(name)) {
student = potential;
}
}
return student;
}
If this is the case then passing the returned student into the remove function should work, however if you have created a new instance of Student then this may not work.
Can you show me the code which calls remove and also the code for Student?
Thanks.