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

  • Home
  • SEARCH
  • 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 8097161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:40:18+00:00 2026-06-05T21:40:18+00:00

First, I’m speaking about the default hashCode() method here and not something overridden. When

  • 0

First, I’m speaking about the default hashCode() method here and not something overridden.
When we create a new object, ‘new’ operator returns the memory address of that object it creates; which in java we say it returns reference more generally. What I want to know is, is this the same as the value returned by the hashCode()?

What I BELIEVE is they are same. But then again, when we have more than 2^32 objects and given hashCode() returns an integer (2^32 different numbers) there will be collisions all over and when we pass objects it would be a real mess. How does JVM deal with?

  • 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-05T21:40:20+00:00Added an answer on June 5, 2026 at 9:40 pm

    When we create a new object, ‘new’ operator returns the memory address of that object it creates; which in java we say it returns reference more generally.

    Well, a reference certainly doesn’t have to be an address. It’s a way of referring to an object – the exact value of the bits depends on the JVM implementation.

    What I want to know is, is this the same as the value returned by the hashCode()?

    Not necessarily. You certainly shouldn’t try to make any assumptions on that front. Again, it’s an implementation detail.

    It’s worth remembering that while the garbage collector can move objects around in memory (updating references as it goes), the hash code must not change based on this, which is an argument against your suggestion.

    But then again, when we have more than 2^32 objects and given hashCode() returns an integer (2^32 different numbers) there will be collisions all over and when we pass objects it would be a real mess.

    There will be hash code collisions, yes. That’s unavoidable – anything using hash codes needs to take the possibility of collisions into account. There can’t be reference collisions though – a JVM which is able to support more than 232 values concurrently clearly can’t just make the hash code and the reference have the same value.

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

Sidebar

Related Questions

First, please tell me if I'm not allowed to ask about this protocol here...
first I used onDestroy() method as below to make something when my app is
First I read-in a csv and create an xts object. require(quantmod) sugar <- as.xts(read.zoo(SUGAR.CSV,
first off I'm a noob to PHP but here is my problem. I am
First I want to thank you guys here, because your posts have gotten me
First time posting here, will try to be succinct. This is a classic 'can't
First off, I'm pretty new so I hope I hadn't missed anything too trivial.
First the apologies, i'm not sure if my question title even accuratly explains what
First off I have an app that provides the user information about the amount
First of all there is a question with the same title here on SO

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.