I have the following list. I'd like to print the values using lambda and method reference. The first lambda expression works, but I have no idea how to print the values using the method reference, because I am getting the compilation error.
List<String> letters = Arrays.asList("a","b","c");
System.out.println("Lambda upperCase forEach");
letters.forEach(l -> System.out.println(l.toUpperCase))); //it works
System.out.println("Method Reference upperCase forEach");
letters.forEach(System.out::println(String::toUpperCase))); //compilation error
How to print the values using method reference?