2021-06-08 14:23:48 +02:00
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
2022-02-04 17:28:24 +01:00
[source,text]
2021-06-08 14:23:48 +02:00
----
if (variable.equals(null)) { /* ... */ } // Noncompliant - "variable" is really null, a NullPointerException is thrown
----
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,text]
2021-06-08 14:23:48 +02:00
----
if (variable == null) { /* ... */ } // Compliant
----
2022-01-25 18:36:46 +01:00
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]