Call a method on the return value of a method reference
<p>I have a stream of files that I want to filter based on the ending of the file name:</p>

<pre><code>public Stream&lt;File&gt; getFiles(String ending) throws IOException {
    return Files.walk(this.path)
            .filter(Files::isRegularFile)
            .map(Path::toFile)
            .filter(file -&gt; file.getName().endsWith(ending));
}
</code></pre>

<p>While the lambda in the last line is not bad, I thought I could use method references there as well, like so:</p>

<pre><code> .filter(File::getName.endsWith(ending));
</code></pre>

<p>Or alternatively wrapped in parentheses. However, this fails with <code>The target type of this expression must be a functional interface</code></p>

<p>Can you explain why this doesn't work?</p>