Consider I have a Java object Student
only with getters and setters that I cannot change, and two Lists – students1
and students2
– both of type ArrayList<Student>
.
How can I call students1.removeAll(students2)
by passing my own equals()
method?
This is because I cannot modify the Student
class.