title: How can I simulate pass by reference in Java?
body: <p>I'm a complete Java noob.  I know that Java treats all parameters as pass by value and there are several other threads where people explain this.</p>
  
  <p>For example, in C++ I can do:</p>
  
  <pre><code>void makeAThree(int &amp;n)
  {
     n = 3;
  }
  int main()
  {
     int myInt = 4;
     makeAThree(myInt);
     cout &lt;&lt; myInt;
  }
  </code></pre>
  
  <p>Which will output 3.  I know that in Java, all parameters are passed by value and thus you can not manipulate the parameter passed in.  Is there a standard way to <em>simulate</em> pass by reference in Java?  Is there no way to call a function that manipulates a variable passed in?  It's tough for me to wrap my head around the idea of there being no way to do this.</p>