title: How do I swap two integers in an array, where my method takes in two integers and an array from main?
body: <p>I call my swap method in main, but it doesn't change anything. What am I doing wrong?</p>
  
  <pre><code>public static void main(String[] args){
  
  
      int mainArr[] = new int[20];
  
      for(int i = 0; i&lt;mainArr.length; i++){
      swapper(3, 14, mainArr);
      System.out.print(i + mainArr[i] + " ");
      }
  }
  
  
  public static void swapper (int a, int b, int[] mainArr){
      int t = mainArr[a];
      mainArr[a] = mainArr[b];
      mainArr[b] = t;
  }
  </code></pre>
  
  <p>My code yields</p>
  
  <pre><code>0, 1,  2, 3,...19 
  </code></pre>
  
  <p>in normal ascending order, where I want it to swap the 4th and 15th element. </p>