如何散列在java中的作品? [英] how does hashing in java works?

查看:127
本文介绍了如何散列在java中的作品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图想办法的有关散列在java中。 如果我想一些数据存储在一个HashMap例如,将它具有某种潜在的哈希表与hashvalues​​? 或者,如果有人能够给如何散列以良好的工作和简单的解释,我真的AP preciate吧。

I am trying to figure something out about hashing in java. If i want to store some data in a hashmap for example, will it have some kind of underlying hashtable with the hashvalues? Or if someone could give a good and simple explanation of how hashing work, I would really appreciate it.

推荐答案

在Java中的哈希值是通过的 公众诠释哈希code() 这是在对象类中声明,它是对所有的基本数据类型实现的。一旦你实现你的自定义数据对象的方法,那么你就不需要担心如何将这些在被Java提供的其他数据结构中使用。

Hash values in Java are provided by objects through the implementation of public int hashCode() which is declared in Object class and it is implemented for all the basic data types. Once you implement that method in your custom data object then you don't need to worry about how these are used in miscellaneous data structures provided by Java.

的说明:实施该方法需要也具有的 公共布尔等于(对象o) 以一致的方式实施。

A note: implementing that method requires also to have public boolean equals(Object o) implemented in a consistent manner.

这篇关于如何散列在java中的作品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆