I'm getting the error
no suitable method found for add(Object), method Collected.add(Student is not applicable)
when I try the following code. I swear I've done it this way before? So confused. Appreciate any insights. Cheers
//Sort and display list of Student objects by sortBy (surname or id)
public static void sortAndDisplayStudents(String sortBy, ArrayList<Object> objList) {
ArrayList<Student> students = new ArrayList<>();
//Add all Objcets in objList that are a Student
for(Object s: objList) {
if(s instanceof Student) {
students.add(s);
}
}
}