Java ArrayList with Objects and compareTo

preview_player
Показать описание
How to code up ArrayLists of objects with compareTo
Рекомендации по теме
Комментарии
Автор

I followed everything you said till 20:00....
can you explain how people do

Collections.sort(presidents)
here presidents is the arraylist to be sorted and it is just passed into this sort method
and the compareTo accepts one parameter

public int compareTo(President){}

So my question was how do you know which object is this method going to take when you pass the complete arraylist?
I mean how does it know which object to compare to another object
I hope you're getting me

Name-pnrf