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 8085925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:17:19+00:00 2026-06-05T18:17:19+00:00

I know when we are passing objects we are passing its reference as a

  • 0

I know when we are passing objects we are passing its reference as a value. But this value you get is using the hashcode() method right (according to my tests it’s the same)? Since hashcode() is not the memory address and not guaranteed to get unique values all the time, can there be strange things happen like collisions when passing objects?

(Assuming hashcode() hasn’t be overridden, i.e., it returns the same value as System.identityHashCode() )

Three are many like this questions, but I can’t find a relevant resource which discuses what is that value being passed and how do you get it?

EDIT:
Here is my test. The default toSting() uses the hashCode() inside and converts it to a hex value. So when we are passing objects, is this the value being passed? Or what does java do to keep track of all the objects (being passed) so there won’t be any reference collisions?

Object o = new Object();
System.out.println(o);
System.out.println(o.toString()); //both prints same thing - java.lang.Object@10385c1
  • 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-05T18:17:20+00:00Added an answer on June 5, 2026 at 6:17 pm

    hashcode() is not involved in any way with Java’s internal memory storage. It’s just a method that is supposed to return a unique value that can represent an object.

    Now, it just so happens that a nice way to get a unique value to represent an object is to use its internal memory address. And that’s what the default implementation of hashcode() does. But the fact that hashcode() uses a memory address does not mean that hashcode() defines the memory address.

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

Sidebar

Related Questions

I know that when it comes to passing objects in java, the reference of
I apologize if this was asked somewhere else, but I do not know how
I have this method with its delegate that is used to append text to
Sorry but this is really confusing me and I know the answer is staring
Ok I know this is a long shot. I am using asp.net mvc on
I want to know what the best practice is for passing values (sometimes multiple
I know for a matter of fact that Type cannot be used when passing
i want to know which parsing method is best to use among Simple XML
Is there a way to get the address of an object? This is for
Possible Duplicate: In PHP (>= 5.0), is passing by reference faster? Say I'm dealing

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.