1. Concept:
The hash is actually just a concept, and there is no real point. Its purpose is to ensure that the data is evenly distributed within a certain range. So it is perfectly possible to generate the same hash code for different data.
Now is the Java Virtual machine in the perspective of the layout of the memory, stand in the Java Virtual machine angle, in memory there are many many objects, here with an ellipse to represent the object. When a program runs, there may be many objects in memory allocated, then for the Java Virtual machine, it needs to find the address of these objects, how to find the address of these objects? Java Virtual opportunity uses a table to record where each object is located, and this table is generally encoded with a hash code, each object has its own unique hash code, according to this code can find the relevant object, that is, according to this code you can uniquely determine the object, And can quickly determine the location of this object, you can simply understand the role of hash coding. But Java itself is a bit of a problem with the implementation of hash coding, it can be two objects, the content is different, but their hash code can actually be the same, and this probability is very high.
2. The implementation of the hash code is a bit problematic, it may be two objects, the content is different, but their hash code can actually be the same, and this probability is very high?
A: Of course, it is possible, in fact, as long as you understand. Hashcode is a 32-bit integer, so long as there are more than 2^32 objects in memory, there must be at least two hashcode of the same object.
Java Fundamentals Hardening 49:java in hash code