Why does a Java method reference with return type match the Consumer interface?
<p>I am confused by the following code</p>

<pre><code>class LambdaTest {
    public static void main(String[] args) {
        Consumer&lt;String&gt;         lambda1 = s -&gt; {};
        Function&lt;String, String&gt; lambda2 = s -&gt; s;

        Consumer&lt;String&gt;         lambda3 = LambdaTest::consume; // but s -&gt; s doesn't work!
        Function&lt;String, String&gt; lambda4 = LambdaTest::consume;
    }

    static String consume(String s) { return s;}
}
</code></pre>

<p>I would have expected the assignment of lambda3 to fail as my consume method does not match the accept method in the Consumer Interface - the return types are different, String vs. void. </p>

<p>Moreover, I always thought that there is a one-to-one relationship between Lambda expressions and method references but this is clearly not the case as my example shows.</p>

<p>Could somebody explain to me what is happening here?</p>