I want to remove an object from an ArrayList based on the students name and each object has 5 elements. THE QUESTION: how do I remove the object from the text file.
ArrayList<Student> studentList= new ArrayList<Student>();
Iterator iter = studentList.iterator();
public DVD remove(String removeName) {
while (iter.hasNext()) {
for (Student stu : studentList) {
if (stu .GetName().toUpperCase().contains(removeName.toUpperCase())) {
System.out.println("Found And Removed");
iter.remove();
return stu ;
}
System.out.println("Not Found");
}
}
return null;
}
Each student is read in from a text file. With one element per line.
Ex:
John Smith
Undergrad
21 years old
2010
2014
Pocahantas
Professor
369 years old
1599
1603
Etc... // new person
etc....