且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么必须重写Hashmap的哈希码和equals方法?

更新时间:2022-11-16 12:07:29

当您要将对象用作使用哈希的集合中的有用哈希键时,它们是必需的。

They are required when you want to use your objects as useful hashing keys into collections that use hashing.

您是否尝试过添加有意义的 Student 对象?
首先了解

Have your tried to add the Student objects which are meaningfully equal? First understand the significance of equals method in java

阅读等于和哈希码的重要性