title: Java recursion and Merge Sort
body: <p>I'm trying to write a simple merge sort program in Java, I'm seeing a lot of red in Eclipse. I'm still a beginner, and don't quite see whats wrong. thanks.</p>
  
  <p>-Kyle</p>
  
  <pre><code>public class merge{ 
  public static int[] mergeSub(int[] array, int left, int right){
          if(left&lt;right)
          {
          int mid = (left+right)/2;
          int[] a = mergeSub(array, left, mid);
          int [] b = mergeSub(array, mid+1, right);
          return merge(a, b);
  
  }
          int[] arr=new int[1];
          arr[0]=arr[left];
          return arr;
  }
  
  static int[] merge(int[] left, int[] right){
          int index =0; int indexLeft =0; int indexRight=0;
          int[] result = new int[left.length+right.length];
  
          while(indexLeft&lt;left.length &amp;&amp; indexRight&lt;right.length){
                  if(left[indexLeft] &lt;= right[indexRight])
                  {
                          result[index]=left[indexLeft];
                          index++;
                          indexLeft++;
  
                  }
                  else{
                          result[index]=right[indexRight];
                          index++;
                          indexRight++;
                  }
          }
  
          if (indexLeft&lt;left.length){
                  while(indexLeft&lt;left.length){
                          result[index]=left[indexLeft];
                          indexLeft++; index++;
                  }
          }
          if (indexRight&lt;right.length){
                  while(indexRight&lt;left[indexRight]){
                          result[index]=right[indexRight];
                          indexRight++; right[indexRight]++;
                  }
          }
          return result;
  }
  
  
  
  public static void main(String args[]){
  
          int[] array = {2, 4, 5, 7, 5, 6, 3, 5, 7, 8};
          System.out.println(mergeSub(array, 0, 9));
  }}
  </code></pre>