title: Remove the middle element if the array length is odd, or the middle two elements if the length is even.
body: <p>I am trying to figure out how to remove the middle elements from an array if it has an even length and also the middle element if the array's length is odd. The program runs when I compile it, however nothing changes in the results.I am also not sure if I am using the System.arraycopy method correctly(the first position is the original array, the second is where you want to start copying, the third is the destination array, the fourth is the starting position of the destination array, and the last position is the number of array elements to copy) Here is the code I have so far: </p>
  
  <pre><code>public void removeMiddle(int[] values)
  {
    //lets say the array size is 10 
     boolean even = (values.length % 2 == 0); 
     int middle1 = values.length/2; 
     int middle2 = values.length/2 - 1; 
  
  
     if(even)
     {
         int[] copy = new int[values.length - 2]; 
         //copying the elements 0-3 to the new array
       System.arraycopy(values, 0, copy, 0, copy.length - middle1 -1);
       //copying the last 4 elements to the new array 
       System.arraycopy(values, middle1 + 1,copy, middle1, copy.length-middle2 - 1); 
      } 
      else if(!even)
      {
         int[] copy = new int[values.length - 1]; 
         //copying elements 0-3
         System.arraycopy(copy,0,copy, 0, copy.length - middle1 -1);
         System.arraycopy(copy,middle1 +1 ,copy, middle1 + 1, copy.length - middle1 -1 );
  
      }
  
  
  }
  </code></pre>