Inspectopedia
 
2024.3

Pattern variable can be used

Warning
New
Last modified: 03 December 2024

Reports local variable declarations that can be replaced with pattern variables, which are usually more compact.

Example:

Can be replaced with:

This inspection depends on the Java feature 'Patterns in 'instanceof'', which is available since Java 16.

New in 2020.1