How objects are allocated in array?
<p>I want to improve my knowledge about memory model of programming languages (particulary in Java), so I have one question.</p>

<p><strong>Here is very simple code:</strong></p>

<pre><code>// Allocating memory in heap for SimpleObject's instance
// Creating reference to this object with name so1
SimpleObject so1 = new SimpleObject();


// Allocating memory in heap for array of 10 references to SimpleObject's objects
// Now I know, that array stores only references to the objects
// (Previously I thought that array stores objects)
// Then we create reference to this array with name soArray
SimpleObject[] soArray = new SimpleObject[10];
</code></pre>

<p><strong>Now the question:</strong></p>

<pre><code>// What is going on here?
soArray[0] = so1;
// object so1 had been really moved to memory area of soArray?
// And so1 reference have been updated to new memory address?

// Or we just had assigned so1 object's reference to soArray[0] element?

// Or so1 object had been copied to the soArray[0]? 
// Then original so1 object has been deleted and all links to it had been updated?
</code></pre>

<p>If you know, how it works in other languages, such as (C, C++, C# or other), please answer, I will be glad to know it.</p>

<p><strong>Everybody know, that ArrayList can be faster than LinkedList, because elements of array could be stored in CPU cache, while if we working with LinkedList, CPU has to get next object from RAM each time.</strong></p>

<p><strong>So how could it work, if  at first I had created object in heap and only then I had put object in array?</strong></p>

<p>UPD: Thank you guys, now I understand how array is working, but what about caching array in CPU cache in that way?</p>
