==
First, you have to explain that the Java data types are divided into basic data types and reference data types.
There are 8 types of basic data:
Float type: float (4 byte), double (8 byte)
Integer: Byte (1 byte), short (2 byte), int (4 byte), Long (8 byte)
Character type: char (2 byte)
Boolean Type: Boolean
When compared by using the base data type, the actual value is compared, compared with the reference data type, and the address stored in memory is compared.
-----------------------------------------------------------------------------------
equals
First, Equals is the method defined in the class, not the same Equals method
eg
Object class
Public boolean equals (Object obj) { return (this = = obj); }
Visible for object,equals and = = Consistent
For other classes, the Equals method is overridden to determine whether the values are equal .
For example, the string class overrides the Equals method to compare whether strings stored by a pointed string object are equal.
-----------------------------------------------------------------------------------
Hashcode
Here is a brief introduction to the hash table, note the following three words: Key keyword, mapping relationship f (key) also known as hash function, hash value
Hashing technology is to establish a deterministic relationship between the storage location of the record and its key words, the keyword key through the mapping relationship f (key) to derive the hash value, that is, the storage location, the storage location is a contiguous storage space, called a hash table .
The Hashcode method is to map the object-related information (such as the object's storage address, the object's field, and so on) to a numeric value according to certain rules.
If two objects hashcode the same, does not mean that they are really equal, you have to confirm with equals again
If two objects hashcode different, it means they are not equal.
= =, equals and hashcode