Inspectopedia
 
2024.3

Lambda can be replaced with anonymous class

Info
New
Last modified: 03 December 2024

Reports lambda expressions that can be replaced with anonymous classes.

Expanding lambda expressions to anonymous classes may be useful if you need to implement other methods inside an anonymous class.

Example:

After the quick-fix is applied:

This inspection depends on the Java feature 'Lambda expressions', which is available since Java 8.