I know that Java's Lambda expression can replace a parameter whose type is an Interface (only contains one method), but why I can execute code like this:
String[] myArray = new String[3];
Arrays.sort(myArray, (a, b) -> {return b.compareTo(a);});
In this case, the lambda expression (a, b) -> {return b.compareTo(a);}
replaces an object of Comparator
interface, but Comparator
interface has more than one method, why?