Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7768625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:57:40+00:00 2026-06-01T15:57:40+00:00

How is hashCode() implemented? My assumption is that it uses the object memory location

  • 0

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 looked at Hash : How does it work internally? but it does not answer my question.

Yes I could download the SDK, but before I do that and look at the code, perhaps someone else already has knowledge of it.

Thanks 🙂

EDIT:
I know it should be overridden and such, so please try to stay on topic 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:57:41+00:00Added an answer on June 1, 2026 at 3:57 pm

    Of course it is implementation specific, but generally the hash code for an object will be computed lazily and stored in the object header. Odd things are done with headers to keep them small whilst allowing complex locking algorithms.

    In the OpenJDK/Oracle JVM the usual method of computing the initial hash code is based on the memory address at the time of the first request. Objects move about in memory, so using the address each time would not be a good choice. The hash code isn’t the actual address – that would typically be a multiple of eight which isn’t great for using straight in a hash table particularly with a power of two size. Note identity hash codes are not unique.

    HotSpot has build time options to always use zero or use a secure random number generator (SRNG) for testing purposes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The JDK documentation for java.lang.String.hashCode() famously says: The hash code for a String object
I am trying to create a quick hashcode function for a complex number class
I have an object which has one field- double[] _myField it's hashcode is public
I have implemented a web service(.asmx) using .NET framework that returns me a hash
I have this hashCode function that I have been trying to implement with Eclipse
I have an object in a LinkedHashSet that implements equals , hashCode and compareTo
How should model class's equals and hashcode be implemented in Hibernate? What are the
What value does the hashCode() method return in java? I read that it is
I have a vector class with hashCode() implemented. It wasn't written by me, but
First some background: I already have a Result class that I've implemented to carry

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.