Top "Method-reference" questions

Method references are part of the Java 8 lambda feature set.

Java 8 pass method as parameter

Currently getting into Java 8 lambda expressions and method references. I want to pass a method with no args and no …

java lambda java-8 method-reference
New object instantiation when using Java 8 streams

Is there a differnce in using the following contstructs, other than slightly better readability in the latter? someList.stream().map(…

java lambda java-8 java-stream method-reference
Use method reference with parameter

I just started learning Java streams and faced a problem. Please take a look at a the following example. This …

java lambda java-stream method-reference functional-interface
The target type of this expression must be a functional interface in MethodReferences

Why does the following code not compile. Consumer con = (s) -> System.out::println; It says The target type …

java-8 method-reference
Static context cannot access non-static in Collectors

I have group of students. First I want to group them by the marks. Then I want to further group …

java java-8 java-stream method-reference collect
Comparator.reversed() does not compile using lambda

I have a list with some User objects and i'm trying to sort the list, but only works using method …

java lambda java-8 comparator method-reference
Java 8 Method Reference to non-static method

Why this doesn't work? I get compiler error "Cannot make static reference to the non static method print..." public class …

java java-8 method-reference
What is the equivalent lambda expression for System.out::println

I stumbled upon the following Java code which is using a method reference for System.out.println: class SomeClass { public …

java lambda java-8 method-reference
Why Comparator.comparing doesn't work with String::toLowerCase method reference?

I am trying to sort an array of Strings by reverse order (ignoring case), without modifying it, and just printing …

java comparator java-8 java-stream method-reference
SONAR: Replace this lambda with a method reference

Sonar tells me "Replace this lambda with a method reference" public class MyClass { private List<SomeValue> createSomeValues(List&…

java lambda java-8 sonarqube method-reference