title: How do pointers work with primitive types in Java?
body: <p>I was reading <a href="https://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it">What is a NullPointerException, and how do I fix it?</a>, and in the accepted answer, I read something that I did not quite understand:</p>
  
  <blockquote>
  <pre><code>int x;
  x = 10;
  </code></pre>
    
    <p>In this example the variable x is an int and Java will initialize it
    to 0 for you. When you assign it to 10 in the second line your value
    10 is written into the memory location pointed to by x.</p>
  </blockquote>
  
  <p>I thought for primitive types, the variable was the memory address of the actual value; where as for complex types, the variable was merely the memory address of a pointer to the actual value.  But the quoted answer above tells me I am wrong.  It says "the memory location pointed to by x."</p>
  
  <p>So if x is pointing to a memory address which stores the actual value, how is a primitive type different from a complex type?  I did not know primitive types even had pointers.  How do pointers work with primitive types?</p>