...
As a general rule, use the Object.equals()
method to check whether two objects are abstractly equal to each other and have equivalent contents and use the equality operators ==
and !=
to test whether two references specifically refer to the same object. This latter test is referred to as referential equality. Also see MET09-J. Classes that define an equals() method must also define a hashCode() method .
...