Linked Questions
12 questions linked to/from What is an "internal address" in Java?
-2 votes
5 answers
600 views
What does hashcode comprises of and does it contains memory address of the object [duplicate]
For an object of class CheckToString, when I give the object or the objectName.toString() as an argument to System.out.println() ie try to print it, i get the output as follows: CheckToString@19821f ...
64 votes
7 answers
34k views
How do hashCode() and identityHashCode() work at the back end?
How do Object.hashCode() and System.identityHashCode() work at the back end? Does identityHashCode() return the reference of the object? Does hashCode() depend on the content or address of the object? ...
35 votes
5 answers
22k views
What is a native implementation in Java? [duplicate]
If we look at the Java Object class then we can find some of the methods like: public native int hashCode() protected native Object clone() What are these natives and how do these methods work?
25 votes
3 answers
4k views
Java Object.hashCode() - address or random()?
I'm trying to understand the native implementation of the hashCode() method. What exactly does this method return? Is it a memory address or is it a random value?
14 votes
8 answers
6k views
Why hashCode() returns the same value for a object in all consecutive executions?
I am trying some code around object equality in java. As I have read somewhere hashCode() is a number which is generated by applying the hash function. Hash Function can be different for each ...
10 votes
5 answers
6k views
How does Object.toString() get the "memory address" and how can I mimic it
The toString method of Object is unique in that it seems to be the only place in Java where the memory address is viewable. How does Object do this? I would like to know so that I can mimic its ...
7 votes
5 answers
5k views
how is hashCode() implemented in Java
How is hashCode() implemented? My assumption is that it uses the object memory location as the initial number (the seed) on which it runs the hash function. However, this is not the case. I've also ...
3 votes
4 answers
8k views
Does hashcode return the memory address? [duplicate]
Possible Duplicate: what is an objects hashcode How do hashCode() and identityHashCode() work at the back end? I'm not talking about String class or any other class where the hashcode is ...
21 votes
1 answer
974 views
Is there a reason Object.hashCode() is 31-bit?
If you run the following on HotSpot Java 7 64-bit version. int countTopBit = 0, countLowestBit = 0; for (int i = 0; i < 100000000; i++) { int h = new Object().hashCode(); if (h < 0) ...
5 votes
2 answers
592 views
Default behaviour of hashCode() [duplicate]
I continuously run this program on the same machine: class Test { public static void main(String[] args) { Test test = new Test(); System.out.println(test.hashCode()); } } The ...
3 votes
1 answer
623 views
Does Object.toString or Object.hashCode ever give the memory address of the object
It is often claimed that the implementation of Object.hashCode() (the default implementation for all objects) gives the memory address of the object. That claim is often attached to an explanation of ...
1 vote
0 answers
122 views
Is the proxy instance created by Proxy.newProxyInstance suitable for the key of HashMap?
I need to take the proxy instance created by Proxy.newProxyInstance as the key of a HashMap. I am not sure if it overwrites the equals and hashcode method of the Object. I am not sure if Object is ...