= = for basic types, the comparison is whether their values are equal, for reference types, the comparison is in memory, and whether they point to the same object in memory.
All classes inherit the Equals () method of the object class, and the default implementation of this method uses the = = comparison, and some classes overload the Equals () method to compare the contents of the object.
We ' ve seen that primitive types and reference types differ significantly in the
They is assigned to variables, passed to methods, and copied. The types also differ
In the They is compared for equality. When used with primitive values, the
Equality operator (= =) Simply tests whether the values are identical (i.e., whether
They has exactly the same bits). With reference types, however, = = compares refer‐
ences, not actual objects. In other words, = = Tests whether, references refer to the
Same object; It does not test whether and objects have the same content.
When working with reference types, there is the kinds of equality:equality of ref‐
Erence and equality of object. It is important to distinguish between these, kinds
of equality. One of the "identical" when talking about
equality of references and the word "equal" when Talking about a distinct objects
that has the same content. To test-nonidentical objects for equality, pass one of the
them to the Equals () method of the other:
All objects inherit a Equals () method (from Object), but the default implementa‐
tion simply uses = = to test for identity of references, not equality of content. A class
That wants-to-allow objects-compared for equality can define its own version of
The Equals () method. Our point class does does this, but the String class does,
As indicated in the code example. You can call the Equals () method on a array, but
It is the same as using the = = operator, because arrays always inherit the default
Equals () method that compares references rather than array content. You can com‐
Pare arrays for equality with the convenience method Java.util.Arrays.equals ().
java = = and equals ()--java In a nutshell, 6th