title: Need help removing middle element in an array if the length is odd, or the middle two if its even
body: <p>Basically, one of my assignments is if the array is odd, remove the middle element or if the array is even, remove the middle two elements.</p>
  
  <p>Here is my code, it may be sloppy  as this is my first year of high school Java.</p>
  
  <pre><code> public static void removeMiddle(int[] arr)
   {
       int size = arr.length;
       if(size % 2 ==0)
       {
           int x = arr.length/2 -1;
           for(int i = x; i &lt;= arr.length - 2; i++)
           {   
               arr[i] = arr[i + 2];
           }
       }
       else
       {
           int z = arr.length/2;
           for(int i = z; i &lt; arr.length - 1; i++)
           {
               arr[i] = arr[i + 1];
           }
       }
   }
  </code></pre>
  
  <p>I was following the pseudo code that the teacher gave us if we got stuck. When I'm running it, it's adding an extra element.</p>
  
  <p>For example, my array 3, 6, -2, 8, 9 changes to 3, 6, 8, 9, 9, after running it</p>
  
  <ol>
  <li><p>Create a local variable named "size" that stores the length of the array passed in.</p>
  
  <pre><code>* 2.  If the size of the array happens to be even, do the following:
  *   a.  Create a local variable that represents the first to remove by assigning it to be one less than
  *       half the size of the array
  *   b.  Run a for-loop starting at the value you just calculated (representing the first to remove) and
  *       terminating at two less than the size of the array
  *       i.  In the for-loop, assign the value at the current index of the array to be the value at two
  *           more than the current index
  * 3.  Otherwise, given the size of the array happens to be odd, do the following:
  *   a.  Create a local variable that represents the first to remove by assigning it to be half the 
  *       size of the array
  *   b.  Run a for-loop starting at the value you just calculated (representing the first to remove) and
  *       terminating at one less than the size of the array
  *       i.  In the for-loop, assign the value at the current index of the array to be the value at one 
  *           more than the current index
  </code></pre></li>
  </ol>
  
  <p>Any suggestions?</p>