Local references and field references memory allocation
<p>An object can contain references to other objects. If you declare these references as class/field variables then as the object itself is created on the heap, the values represented by the field references are stored on the heap.  </p>

<p>So, if i have</p>

<pre><code>public class A {
    int size;
}
</code></pre>

<ul>
<li>I know that if size gets an int value of <code>2</code> then that is stored as part of the object on the heap, but where is the reference i.e. the name size stored ?</li>
<li>Is the name "size" also stored inside of the object on the heap.</li>
<li>How does JVM cross-reference <code>size == 2</code> on the heap ? </li>
<li>When you load up the class it runs in the main thread and each thread will have its own stack. So these field references are not created on the main stack correct?</li>
</ul>
