obj[0], obj[1] and obj[2] are also reference variable and live on the heap ?
I doubt whether obj[0],[1], etc. are reference variables on the heap.
This is just a notation to access an element at a particular index in an array.
The only reference variable is obj here and that is a reference to the array object.
Arrays beings first class objects in
java, they are stored on the heap.
The array object on the heap may have references to the memory location for inidividual elements(if not all elements are stored in contiguous memory location) but they are not obj[0], [1], etc.
FYI:
The reference variables that lie on the heap are member variable references.Class level variable references(static) lie in the method area or more specifically the constants pool for that class.All primitives lie either on the stack or in the constants pool but never on the heap. [ May 09, 2007: Message edited by: Nitesh Kant ]