Inspectopedia
 
2024.3

Invalid method reference used for 'Comparator'

Warning
New
Last modified: 03 December 2024

Reports method references mapped to the Comparator interface that don't fulfill its contract.

Some method references, like Integer::max, can be mapped to the Comparator interface. However, using them as Comparator is meaningless and the result might be unpredictable.

Example:

After the quick-fix is applied: