Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: removed Automated Detection

...

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

Automated Detection

Coverity Prevent 5.0

The BAD_EQ checker can detect instances where the == operator is being used for equality of objects when, ideally, the equals() method should have been used. The == operator could consider the objects to be different, whereas the equals() method would consider them to be the same.

[FindBugs 2008]

ES: Comparison of String objects using == or !=

Related Guidelines

MITRE CWE

CWE ID 595, "Comparison of Object References Instead of Object Contents"

 

CWE ID 597, "Use of Wrong Operator in String Comparison"

[Rogue 2000]

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

...