title: How do I make an array of Comparables
body: <p>I am trying to make arrays of objects that implement the Comparable interface.
  The object of the project is to merge two presorted arrays, of Comparable type, into a single
  sorted array. So far I have:</p>
  <pre><code>public Comparable[] mergeArrays(Comparable[] arrayOne, Comparable[] arrayTwo){
      
      Comparable[] merged = new Comparable[arrayOne.length + arrayTwo.length];
      int i = 0, j = 0;
      
      for(int k = 0; k &lt; merged.length; ++k) {
          if(i &gt;= arrayOne.length) {
              merged[k] = arrayTwo[j];
              ++j;
          }
          else if(j &gt;= arrayTwo.length) {
              merged[k] = arrayOne[i];
              ++i;
          }
          else {
              if(arrayOne[i].compareTo(arrayTwo[j]) &gt; 0) {
                  merged[k] = arrayTwo[j];
                  ++j;
              }
              else if(arrayOne[i].compareTo(arrayTwo) &lt; 0) {
                  merged[k] = arrayOne[i];
                  ++i;
              }
              else {
                  merged[k] = arrayOne[i];
                  merged[k + 1] = arrayTwo[j];
                  ++k;
                  ++j;
                  ++i;
              }
          }
      }
      return merged;
  }
  </code></pre>
  <p>This does not throw any exceptions until run time, where I get a type mismatch between
  int[] and Comparable[]. The method must have two formal parameters of arrays of objects that implement the comparable interface. The method has to return an array of Comparable.</p>