int compareWord(String a, String b) has the same signature as the int compare(String o1, String o2) method of the Comparator<String> interface. Therefore, it can be used as an implementation of this interface.
This is a shorter way to write:
Collections.sort(lst, new Comparator<String> () { public int compare (String o1, String o2) { return compareWord(o1,o2); } });
In Java 8, any functional interface, such as a Comparator (that is, an interface that has one abstract method), can be implemented using a method method reference that has a signature that matches the signature of the abstract interface method.
source share