<p>I am trying to understand the process of declaration and assignment of a primitive type at the back stage.</p>

<ol>
<li><code>int i;</code></li>
<li><code>i = 3;</code></li>
</ol>

<p>For 1),  on the memory stack, it assigns a space for storing an int type value named i
For 2),  it assigns the value 3 to the space preserved above</p>

<p>Is there a memory address there?
From my impression, memory address is always associated with the objects on the heap?</p>

<p><strong>Update:</strong></p>

<p>Regarding the replies: </p>

<p>So, for every variable on the stack, they are all assigned a memory address as well just like the objects on the heap. Am I correct?</p>

<p>But for Java, this is not the case?</p>

Assuming you're talking about C or C++ (I can't tell), yes. You can access the address like so:
```
```
int i = 3;

int *k = &i; // k now is a pointer to i

*k = 4; // assigns the value k points to (i) to 4, i is now 4
```
```