Files
openide/java/java-impl/resources/inspectionDescriptions/InvalidComparatorMethodReference.html
2025-02-05 04:43:28 +00:00

20 lines
632 B
HTML

<html>
<body>
Reports method references mapped to the <code>Comparator</code> interface that don't fulfill its contract.
<p>
Some method references, like <code>Integer::max</code>, can be mapped to the <code>Comparator</code> interface.
However, using them as <code>Comparator</code> is meaningless and the result might be unpredictable.
</p>
<p>Example:</p>
<pre><code>
ArrayList&lt;Integer&gt; ints = foo();
ints.sort(Math::min);
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
ArrayList&lt;Integer&gt; ints = foo();
ints.sort(Comparator.reverseOrder());
</code></pre>
<!-- tooltip end -->
</body>
</html>