List<Student> list = new ArrayList<Student>();
list.add( new Student(3500,5/20/2020) );
list.add( new Student(3500,4/20/2019 );
list.add( new Student(3500,3/20/2018) );
list.add( new Student(3600,6/20/2020) );
list.add( new Student(3600,5/20/2019) );
list.add( new Student(3700,5/20/2020) );
list.add( new Student(3700,5/19/2018) );
public class Student{
int studnum;
Date enrolldate;
}
How can I remove elements so that the arraylist contains only those elements with only one of the student numbers and the latest date for that student number? I am using JDK1.7. I am at a secure site and they are not ready to upgrade the JDK version, so removeIf will not be available.
Unique student number and there latest dates:
3500,5/20/2020
3600,6/20/2020
3700,5/20/2020