title: Java, Shifting Elements in an Array
body: <p>I have an array of objects in Java, and I am trying to pull one element to the top and shift the rest down by one.</p>
  
  <p>Assume I have an array of size 10, and I am trying to pull the fifth element. The fifth element goes into position <code>0</code> and all elements from 0 to 5 will be shifted down by one.</p>
  
  <p>This algorithm does not properly shift the elements:</p>
  
  <pre><code>Object temp = pool[position];
  
  for (int i = 0; i &lt; position; i++) {                
      array[i+1] = array[i];
  }
  array[0] = temp;
  </code></pre>
  
  <p>How do I do it correctly?</p>