For instance, I have an arraylist called StudentListA and StudentListB that contains many students.
StudentListA = {Student 1, Student 2, Student 3....}
StudentListB = {Student A, Student B, Student C....}
In each student, they have their own attributes such as name, address, gpa etc. How do I compare if Student 1 has the same attribute value with Student A, and so on.
For now I am thinking of something like this:
int i = 0;
for (Student student : StudentListA){
if(student.getName().equals(studentListB.get(i).getName() &&
student.getAddress().equals(studentListB.get(i).getAddress()....){
//Do smtg
}
i++;
}
Is there an easier way to do this? Because I have quite a handful of attributes. I want to know if the first and second list have the exact same students or not.