哈希码编号是否代表内存地址? [英] Does hashcode number represent the memory address?
本文介绍了哈希码编号是否代表内存地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经知道hashcode是一个唯一标识引用号,它是一个十六进制数。
我的疑问是,引用号是否代表对象的内存地址?
I have learned that hashcode is a Unique Identification reference number, which is a hexadecimal number.
My doubt is, does the reference number represents the memory address of the object?
例如:
Employeee e1=new Employee();
System.out.println(e1.hashcode());
此代码是否会返回我对象的内存地址?
Will this code return me the memory address of my object?
推荐答案
Hashcode不是唯一标识。它只是一个可以帮助您区分对象的数字。两个不同的对象可能具有相同的哈希码,并且没问题。
Hashcode is not a unique identification. It's just a number that helps you distinguish objects. Two different objects may have the same hash code and it is fine.
HashCode特征:
HashCode characteristics:
- 如果obj1和obj2相等,它们必须具有相同的哈希码。
- 如果obj1和obj2具有相同的哈希码,则它们不必相等。
这篇关于哈希码编号是否代表内存地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文