title: How to do a "cross-over" with two integer arrays
body: <p>I'm trying to learn about genetic algorithms and am currently working on "crossing over" two "genes".
  A gene is an integer array, consisting of ones and zeros. To exemplify my problem let's say we have two genes.</p>
  
  <pre><code>int[] geneA = {1,0,0,0,0};
  int[] geneB = {0,1,1,1,0};
  </code></pre>
  
  <p>The expected result from a cross-over, for example at position 3 would be:</p>
  
  <pre><code>geneA = [1,0,0,1,0]
  geneB = [0,1,1,0,0]
  </code></pre>
  
  <p>Meaning that every element at the index of 3 or above would be swapped with the equivalent element of the other gene. To achieve this I wrote the following method:</p>
  
  <pre><code>private void crossOver(int[] geneA, int[] geneB, int pos) {
      int copyA[];
      int copyB[];
      copyA = geneA;
      copyB = geneB;
      for(int i = pos; i &lt; geneA.length; i++) {
          geneA[i] = copyB[i];
          geneB[i] = copyA[i];
      }
      System.out.println(Arrays.toString(geneA);
      System.out.println(Arrays.toString(geneB);
  }
  </code></pre>
  
  <p>However, it seems that the elements of geneB simply get copied into geneA at the index of 3 or higher. 
  The console output is as following:</p>
  
  <pre><code>[1, 0, 0, 1, 0]
  [0, 1, 1, 1, 0]
  </code></pre>
  
  <p>Any explanations or help are highly appreciated. Thanks in advance!</p>