I am new to Java and cannot seem to figure this piece out, any help is appreciated. I am wanting to iterate through my code to find any entry of "3" and remove it. The code I have does not give an error, however when I print it, the entry with "3" is still there.
remove("3");
public static void remove(String studentId){
Iterator itr = myStudent.iterator();
for(Student s: myStudent){
while(itr.hasNext()){
Object element = itr.next();
if(element.equals("3")){
itr.remove();
}
}
System.out.println(s.getstudentId() + " No ID");
} }