Linked Questions

-2 votes
5 answers
600 views

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 ...
Ankit Vashishta's user avatar
64 votes
7 answers
34k views

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? ...
Himanshu's user avatar
  • 991
35 votes
5 answers
22k views

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?
dinsim's user avatar
  • 2,495
25 votes
3 answers
4k views

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?
johnny-b-goode's user avatar
14 votes
8 answers
6k views

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 ...
Vijay Shanker Dubey's user avatar
10 votes
5 answers
6k views

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 ...
castletheperson's user avatar
7 votes
5 answers
5k views

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 ...
Adrian's user avatar
  • 5,680
3 votes
4 answers
8k views

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 ...
samsamara's user avatar
  • 4,760
21 votes
1 answer
974 views

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) ...
Peter Lawrey's user avatar
5 votes
2 answers
592 views

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 ...
Alex's user avatar
  • 1,001
3 votes
1 answer
623 views

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 ...
Raedwald's user avatar
  • 49.2k
1 vote
0 answers
122 views

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 ...
Jacky's user avatar
  • 9,095