• Post Reply Bookmark Topic Watch Topic
  • New Topic

facts about newly created object?  RSS feed

 
viki Bhardwaj
Ranch Hand
Posts: 74
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers!

Here i am going to ask a question that may be very easy for all but i am curious to know.
the question is- when we create a new object of any class(like class Demo) then by which data structure it going to maintain by JVM.
let me elaborate my issue. suppose i have a normal class Student and i am going to create an object of Student class, so i know that the newly created instance will get memory inside heap.



student will get memory inside heap, that is fine but by which data structure ??? please make me clear my doubt by posting your answer.
Thanks for your time.

-----------------------------------------------------------------------------------------------------------------------------------------------------
viki
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You seem to be asking about the internals of the JVM so I doubt if this implementation detail is specified. You could spend some time trawling through the OpenJDK source but, since you have no access to the ' data structure' hough your Java code, why do you need to know?
 
viki Bhardwaj
Ranch Hand
Posts: 74
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Tookey wrote: why do you need to know?


First i like to say thanks for your reply,
Yes, i am curious to know about, because i faced a question asked by one of my colleague.we were discussing over hashcode() and equals() method .let me explain about confusion we discussed.
1-he asked me that when we print object reference through sop statement then it prints like Student@736e84 where 736e84 is hexadecimal representation of hashcode
and we know that in hashtable objects are inserted according to their hashcode.
so in the student case it prints along with hashcode so does student object also maintain by hashtable data structure??
really i am unable to get what would be the right answer.
please help..

regards:
-viki
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
viki Bhardwaj wrote:
1-he asked me that when we print object reference through sop statement then it prints like Student@736e84 where 736e84 is hexadecimal representation of hashcode


Not necessarily true since a hash code can be up to 32 bits and 6 hex digits is only 24 bits and I have seen system generated 32 bit hash codes. Also, since the JVM can move objects in memory it is not even a simple cut down representation of the address. Other than to suggest once again that you look at the OpenJDK source I can't help. To my mind, life is too short to worry about this irrelevant implementation detail and I suggest that it would be more productive for you to spend your spare time learning more of the language details.
 
viki Bhardwaj
Ranch Hand
Posts: 74
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Tookey wrote:
viki Bhardwaj wrote:
1-he asked me that when we print object reference through sop statement then it prints like Student@736e84 where 736e84 is hexadecimal representation of hashcode


Not necessarily true since a hash code can be up to 32 bits and 6 hex digits is only 24 bits and I have seen system generated 32 bit hash codes. Also, since the JVM can move objects in memory it is not even a simple cut down representation of the address. Other than to suggest once again that you look at the OpenJDK source I can't help. To my mind, life is too short to worry about this irrelevant implementation detail and I suggest that it would be more productive for you to spend your spare time learning more of the language details.



Hi Richard,
Thanks for your reply. I am agree with your point and the thing which i want to know is-
does student object get manage by hashtable data structure internally??
i hope you make me clear my doubt.

thanks
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
viki Bhardwaj wrote:
Hi Richard,
Thanks for your reply. I am agree with your point and the thing which i want to know is-
does student object get manage by hashtable data structure internally??
i hope you make me clear my doubt.

thanks



The objects are stored in the heap -- and having worked with the innards of the JVM for about a year or so (in my previous job), I don't recall anything about the heap that looks like a hashtable. So, I would say "no".

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!