The = = operator is the equality of values for two variables, that is, whether the values in the corresponding memory of the comparison variable are equal. Compare the base data type or two reference variables for equality, and you should use the = = operator.
If the data that a variable points to is an object type, then it involves two memory, the object itself occupies a piece of memory (heap memory), the variable also occupies a piece of memory, the first address of the heap memory. For two reference-type variables, the = = comparison Indicates whether two variables point to the same heap memory, compared to whether the addresses stored by the two variables are equal.
The Equals method is used to compare the contents of two true independent objects, as follows:
String a = new string ("abc");
String b = new String ("abc");
To compare the strings in A and B, use: A.equals (b) Returns the result to true;
At this point, if you compare with A==b, the returned result will be false, because A and B are two different objects, the address is completely different.