Just to add, object references are stored in the stack if created within a method, else it is stored in the heap. Objects created are stored on the heap. Stack memory is the programs memory and Heap memory is outside the program.
Joined: Jun 01, 2005
I don't think object reference will get stored in Heap... If that is going to be stored in Heap ..how it will get garbage collected ..pls explain me ...
about your comment - "how it will get garbage collected", I don't think GC would work that way. In fact it does run on "Heap" by starting from top level objects and then following object graphs to see which objects can be GCed.