Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hexadecimal representation of hash code

 
S Majumder
Ranch Hand
Posts: 349
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
when print the object , why it shows the hexadecimal representation of hash code followed by classnamse@ ?How java internally do this ?

Thanks,
Satya
 
Paul Clapham
Sheriff
Pie
Posts: 20190
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why? Because that's what the writers of the JVM decided to do.

How does the JVM do it? It's just programming. Why do you need to know that?
 
Claude Moore
Ranch Hand
Posts: 747
7
IBM DB2 Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

simply I think standard toString() method is called.

I think that returning className+@+HEX of the hash code was an implementation choice since Java 1.0, a way to return a string without a meaning but at least with a semantic....

You can look at official Java documentation, there's explained how default toString() works.
 
Gaurangkumar Khalasi
Ranch Hand
Posts: 187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
S Majumder wrote:when print the object , why it shows the hexadecimal representation of hash code followed by classnamse@ ?

As Paul has said, Because that's what the writers of the JVM decided to do.

S Majumder wrote:How java internally do this ?


For more information:
http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#toString()
 
S Majumder
Ranch Hand
Posts: 349
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul and Claude for the reply
I know if we override the toString() as per our requirement ....
But I need to know how its actually work behind the back , when the method is not overridden , you can say its just my curiosity ..

regards,
Satya
 
S Majumder
Ranch Hand
Posts: 349
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurangkumar Thanks a lot ,,, for the link .


-Satya
 
Gaurangkumar Khalasi
Ranch Hand
Posts: 187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
S Majumder wrote:Gaurangkumar Thanks a lot ,,, for the link .

You are welcome
 
Paul Clapham
Sheriff
Pie
Posts: 20190
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
S Majumder wrote:But I need to know how its actually work behind the back , when the method is not overridden , you can say its just my curiosity ..


Well, it looks like Gaurangkumar Khalasi has explained that. As for your curiosity, that's all very well, but if you also have the goal of being a Java programmer, then in my opinion you're wasting your time with all of these questions you are posting here.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to see how a method such as Object.toString() is implement, then you can lookup the source code - you can find it in the file src.zip which is in your JDK installation directory.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic