The data types in Java can be divided into two categories:
1. The basic data type, also known as the original data type. Byte,short,char,int,long,float,double,boolean
The comparison between them, applying the double equals sign (= =), compares their values.
2. Composite data type (Class)
When they compare with (= =), they compare the storage address in memory, so unless it is the same new object, their comparison result is true, otherwise the result is false. All classes in Java are inherited from the base class of object, and a method of equals is defined in the base class of object, and the initial behavior of this method is to compare the memory address of the object, but in some class libraries This method is overwritten, such as String, Integer,date in these classes equals has its own implementation, and is no longer a comparison class in the heap memory of the storage address.
For the equals comparison between composite data types, the comparison between them is based on the address value of the location in memory where the Equals method is not covered, because the equals method of object is compared with the double equals sign (= =) . So the result of the comparison is the same as the double equals sign (= =).
The difference between java equals and = =