| Author |
how java variables are stored?
|
|
| rahul8143@gmail.com 2005-08-13, 10:01 pm |
| hello,
In java turorial i read that if code is
int arr[];
arr= new int [100];
then arr is stored on stack and actual array is stored on heap.
what this mean? why same arr variable require space in stack and heap
also?
regards,
rahul
| |
| Tor Iver Wilhelmsen 2005-08-14, 4:01 am |
| rahul8143@gmail.com writes:
> what this mean? why same arr variable require space in stack and heap
> also?
The reference to the array is on the stack, the actual array object is
on the heap.
| |
| Dale King 2005-08-14, 10:02 pm |
| Tor Iver Wilhelmsen wrote:
> rahul8143@gmail.com writes:
>
>
>
> The reference to the array is on the stack, the actual array object is
> on the heap.
But the distinction can get a little blurred with the generational
garbage collector. Objects initially are allocated in the nursery which
is basically a stack. When the nursery fills up any live objects are
moved to the heap. So short-lived objects may never make it to the heap.
--
Dale King
| |
| Mario Winterer 2005-08-18, 6:00 pm |
| Correct.
But: For the development of most of this worlds java applications,
you do not have to care a pap for if it is on the stack or heap - it simply works!
Tex
"Tor Iver Wilhelmsen" <jadedgamer@hotmail.com> wrote in message news:ull359ctd.fsf@hotmail.com...
> rahul8143@gmail.com writes:
>
>
> The reference to the array is on the stack, the actual array object is
> on the heap.
|
|
|
|