Inspectopedia Help

Cast can be replaced with variable

Reports type cast operations that can be replaced with existing local or pattern variables with the same value.


void foo(Object obj) { String s = (String) obj; System.out.println(((String) obj).trim()); }

After the quick-fix is applied:

void foo(Object obj) { String s = (String) obj; System.out.println(s.trim()); }

New in 2022.3

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.16690

Last modified: 29 April 2024