I have seen this code many places but I don't understand how we can pass string.toUpperCase as a method reference in "stream.map(-)" function.? see the below code:
List myList = Arrays.asList("india", "australia", "england");
myList.stream().map(String :: toUpperCase).sorted().forEach(System.out :: println);
My understanding is stream.map method takes java.util.Function<T,U> interface object which contains U apply(T) method. That means, any method which takes one argument and return one value is the "candidate" of method reference and that can be passed in stream.map(..) method as a method reference. But in above code string.toUpperCase method does not take any argument but only returns String value. That means Signature of toUpperCase is not matching with "U apply(T)" function.
So how the above code is working properly?