Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

别拿 byte [] 数组作为 key | Junyu's Blog #15

Open
palexu opened this issue Feb 23, 2021 · 0 comments
Open

别拿 byte [] 数组作为 key | Junyu's Blog #15

palexu opened this issue Feb 23, 2021 · 0 comments

Comments

@palexu
Copy link
Owner

palexu commented Feb 23, 2021

https://palexu.github.io/2017/06/28/2017-06-28-not-use-byte[]-as-key-of-hashmap/

byte[]数组作为key值,只是数组的地址的引用的hashcode,不能够根据byte[]数组的内容来,创建相应的hashcode,也就是所谓的索引key。所以,如果想用byte[]数组来作为map的key值的话,有三种方法: 将byte[],先转化为string 将采用list 将byte[]自己包装,使用byte[]数组的内容来重写hashcode和equals方法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant