code: public static <E> void swap(E[] array1, int array1Index, E[] array2, int array2Index) {
          if(array1[array1Index] != array2[array2Index]) {
              E hold = array1[array1Index];
              array1[array1Index] = array2[array2Index];
              array2[array2Index] = hold;
          }
          
      }
docs: Swap the elements of two arrays at the specified positions.
  
  @param <E> the type of elements in this array.
  
  @param array1 one of the arrays that will have one of its values swapped.
  @param array1Index the index of the first array that will be swapped.
  @param array2 the other array that will have one of its values swapped.
  @param array2Index the index of the second array that will be swapped.