Answer the question
In order to leave comments, you need to log in
Are array elements in Java stored on the stack or on the heap?
Hello, I have a mess in my head.
Arrays themselves in Java are objects, hence they live on the heap.
If the array contains objects, for example objArray [0] = new SomeObject();
, then it is logical to assume that this element is also on the heap.
And if the array consists of primitives, intArray[0] = 1;
are they stored as array instance variables on the heap, or as its local variables on the stack?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question