title: Java method to swap primitives
body: <p>how do I make my swap function in java if there is no method by which we can pass by reference?  Could somebody give me a code?</p>
  
  <pre><code>swap(int a, int b)
  {
       int temp = a;
       a = b;
       b = temp;
  }
  </code></pre>
  
  <p>But the changes wont be reflected back since java passes parameters by value.</p>