The reference to o and s will be the same in RAM. The value in RAM would just be an address representing the location of the Object and String. The compiler is where the difference is taken into account. You told the compiler that reference "o" is an object of type "Object", and the reference "s" is an object of type "String". So the compiler will only let you perform "Object" methods on "o", and "String" methods on "s".
Clear as mud?
Life is good on the Ponderosa,<br />but mind where you step.
The reference to o and s will be the same in RAM. The value in RAM would just be an address representing the location of the Object and String.
I don't think Java guarantees anything about how references, or anything, is really stored in RAM. Java is all about specifying the behaviour and not specifying the implementation any more than necessary.
For instance, it says an int must behave as a signed 32-bit integer, but doesn't say it has to take up 32 bits of RAM. It could take more (e.g. 64). It probably won't take less!
That said, I think your explanation does say how it is likely that most real JVMs would work.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
posted 13 years ago
Thanks. That helps. Mark
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop