Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Use reference equality to determine whether two references point to the same object.

Related Guidelines

MITRE CWE

CWE-595, Comparison of object references instead of object contents
CWE-597, Use of wrong operator in string comparison

Rogue 2000

Rule 79, Use equals(), not ==, to test for equality of objects

Bibliography

[Bloch 2008]Item 69, "Prefer Concurrency Utilities to wait and notify"

[FindBugs 2008]

ES, "Comparison of String Objects Using == or !="

[JLS 2011]

§3.10.5, "String Literals"
§5.6.2, "Binary Numeric Promotion"

...