All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.java.rules.squid.S1318.html Maven / Gradle / Ivy

There is a newer version: 8.6.0.37351
Show newest version

Inexperienced Java developers might expect the Object.equals(Object obj) method to correctly handle the case where the left hand side is null, but that is not the case.

Noncompliant Code Example

if (variable.equals(null)) { /* ... */ }   // Noncompliant - "variable" is really null, a NullPointerException is thrown

Compliant Solution

if (variable == null) { /* ... */ }        // Compliant

Deprecated

This rule is deprecated, use {rule:squid:S2159} instead.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy