title: Swap two elements in a 2D array
body: <p>I write this method for swapping two elements in a 2D array:</p>
  
  <pre><code>    public void swap(Object[][] array, int a, int b) {
      Object temp;
      temp = array[a];
      array[a] = array[b];
      array[b] = temp; // Error, Why?
  }
  </code></pre>
  
  <p>But there is a compile time error in last line.</p>
  
  <p>For example, i want to swap <code>array[i][j+1]</code> and <code>array[i+1][j]</code> elements, How should call this method?</p>
  
  <p>(<code>i</code> and <code>j</code> are int in for loop)</p>
  
  <p><strong>update</strong></p>
  
  <p>Should i swap by element-based ? Or by index-based?</p>
  
  <p>How should be my parameters in <code>swap</code> array?</p>
  
  <p><strong>Update 2</strong></p>
  
  <pre><code>    public void swap(Object[][] array, int i1, int j1, int i2, int j2) {
      Object tempObject = array[i1][j1];
      array[i1][j1] = array[i2][j2];
      array[i2][j2] = tempObject;
  }
  </code></pre>
  
  <p>Is this correct for swapping arbitrary elements of a 2D array?</p>