问题 Java Comparator interface - Here is an example of how Comparator works. My question is : Where is Object type o1 and o2 coming when the method compare(Object o1,Object o2) ? I don't know see any Class invoke the compare() method. I only see Collections.sort(al,new NameComparator()); Please explain, thank you. 回答1: When you call Collections.sort on any collection and pass the comparator reference , The underlying sorting method makes a call to compare method to decide which one is greater