Back to Intellij Community

SimplifiableEqualsExpression

java/java-impl/resources/inspectionDescriptions/SimplifiableEqualsExpression.html

2025.3-rc-2376 B
Original Source

Reports comparisons to null that are followed by a call to equals() with a constant argument.

Example:

if (s != null && s.equals("literal")) {}

After the quick-fix is applied:

if ("literal".equals(s)) {}

Use the inspection settings to report equals() calls with a non-constant argument when the argument to equals() is proven not to be null.