Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between hash code and reference or address of an object?

difference between hash code and reference or address of an object?

like image 596
ManMohan Avatar asked Sep 13 '10 13:09

ManMohan


People also ask

Is hashCode the same as reference?

Two different Objects can have same hashCode . A reference is a unique pointer to an object where hashCode is a convenient computed attribute.

What is the hashCode of an object?

A hash code is an integer value that is associated with each object in Java. Its main purpose is to facilitate hashing in hash tables, which are used by data structures like HashMap.

Is hashCode the same as memory address in Java?

The value returned by hashCode() is by no means guaranteed to be the memory address of the object. According to Java API, the calculation of hashcode is based on 32-bit internal JVM (Java Virtual Machine) address of the Object. It is true that the object moves during execution. But hashcode does not change.

What hashCode means?

What Does Hash Code Mean? Hash code in . NET framework is a numeric value which helps in identification of an object during equality testing and also can serve as an index for the object. The value contained in the hash code is not permanent in nature.


1 Answers

In JavaME, these three things are unrelated.

An object's hashCode is a semi-unique identifier for it.

A reference to an object is a scoped handle on that object.

An object's address is (probably) unobtainable, and certainly useless.

like image 52
Armand Avatar answered Nov 14 '22 14:11

Armand