title: Pass by reference in java?
body: <p>I'm trying to build a litle gam for android GSMs. I hava lots of units and all of them have destinations. To calculate destination I'm using a function called <strong>CalDes</strong>. This function <strong>CalDes</strong> is calculating my unit's speed. So I'm sending some variables into which I have to edit and use em again. For this I have to send these variables with reference. Here is a simple for C++ How to do that in java?</p>
  
  <pre><code>void swap(SomeType&amp; arg1, Sometype&amp; arg2) {
      SomeType temp = arg1;
      arg1 = arg2;
      arg2 = temp;
  }
  ...
  SomeType var1 = ...; // value "A"
  SomeType var2 = ...; // value "B"
  swap(var1, var2); // swaps their values!
  </code></pre>