The short answer is "it's implementation defined - depends on your JVM". If this were C++ code, it would be the perfect reverse of what you said. The reference v is stored on the stack, and it points to an object on the heap. However, as a garbage collecting language, it's not uncommon for JVM's to implement almost everything on the heap, so they could both be on the heap. Of course I'm not certain of this, I'm speaking from 3rd hand knowledge on the Java stuff, although I'm sure of the C/C++ stuff.
|