This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am very new to java world. I have a question regarding reference variable I am creating an object by doing
Blah blah = new Blah();
blah is just a reference to the actual blah object but it doest hold the actual object correct me if i am wrong. i guess blah occupies some space to store the reference to the object. what would be the max. size of blah reference variable and what type of value can it hold.
In the Java VM spec, a reference variable is said to occupy "one stack position", which is typically 32 bits for a 32-bit implementation. But as with many things in Java, the actual size is implementation dependent and not knowable from within your program. In a 64-bit JVM implemenation, a stack slot is probably 64 bits wide.
I'm curious to know why someone learning Java needs or wants to know this? How are you better off knowing this it 32 bits versus 128 bits? Wouldn't it be better to think of the size of a reference as unimportant? Implementation details usually don't clarify anything.
There is no emoticon for what I am feeling!
Joined: Jun 03, 2005
Thanks for your reply Ernest!! Jeff, as a newbie to java world i know not to worry about JVM specs but, i was just curious to know about that.