title: Java - pass a pointer to an object to a function
body: <p>What I want to achieve is something like this:</p>
  
  <pre><code>MyClass object = null;
  doStuff(&amp;object);
  
  // `object` can now be non-null
  </code></pre>
  
  <hr>
  
  <p>What I'm currently doing is this, but I think there must be a better way to achieve this behavior in Java:</p>
  
  <pre><code>MyClassPointer pointer = new MyClassPointer(null);
  // pointer.object is null
  doStuff(pointer);
  
  // pointer.object can now be non-null
  </code></pre>