code: public static <E> void swap(E[] array1, E[] array2) {     
          int minLength = Math.min(array1.length, array2.length);
          
          for(int i = 0; i < minLength; i++) {
              TrivialSwap.swap(array1, array2, i);
          }
      }
docs: Helper method that swaps all the elements of the arrays. This method runs in
  O(<code>Math.min(array1.length, array2.length</code>) time.
  
  @param <E> the type of elements in this list.
  
  @param array1 one array that will have its values swapped.
  @param array2 the other array that will have its values swapped.