4.5. Comparing objects for equality
[3.2] Test equality between Strings and other objects using == and equals()
In section 4.1, you saw how the class String defined a set of rules to determine whether two String values are equal and how these rules were coded in the method equals. Similarly, any Java class can define a set of rules to determine whether its two objects should be considered equal. This comparison is accomplished using the method equals, which is described in the next section.
4.5.1. The method equals in the class java.lang.Object
The method equals is defined in class java.lang.Object. All the Java classes directly or indirectly inherit this class. Listing 4.2 contains the default implementation of the method ...