-1

Possible Duplicate:
How is hashCode() calculated in Java

I know every objects generated in java has hashcodes and also there can be two different objects with the same hashcode.So, i dont know hashcode generation depends on the object type or something else...

Can you suggest me about how hashcodes are implemented in java or what does it depends(based) on?

Community
  • 1
  • 1
Saravanan
  • 11,372
  • 43
  • 143
  • 213
  • 2
    Did you try to search for this topic? Do you think you are the first to have a question regarding this topic? You could have entered `site:stackoverflow.com hashcode java` into Google, or the search engine of your choice, and get a whole lot of answers in no time... Instead of "possible", there should be a "**definite** duplicate" button for such questions on [SO]. – ppeterka Dec 20 '12 at 08:33

2 Answers2

2

hashcodes are usualy implemented for each object and are calculated using the fields that make that object unique and to comply with the hashcode equals contract. If left unimplemented the hashcode of the super class will be used.

The "default implementation" will be objects hashcode which is calculated using it's memory address also known as pointer.

G-Man
  • 1,321
  • 8
  • 15
1

there's a lot of resources about this Try

Community
  • 1
  • 1
MarcDeXeT
  • 264
  • 2
  • 14