title: Java: moving items in array
body: <p>I'm looking to move things around within an Array.</p>
  
  <p>I want to be able to move the last item within the given Array to a spot while moving those in the current location to the right. I want it to move from the first spot to the second, etc. without replacing the item that is currently there.</p>
  
  <p>ex)</p>
  
  <pre><code>a,b,c,d,e
  </code></pre>
  
  <p>Say I want to move to "3" - it would then become</p>
  
  <pre><code>a,b,c,e,d
  </code></pre>
  
  <p>I currently have the following:</p>
  
  <pre><code>public static void moveLastup(String[] stuff, int position) 
  {
      String y = stuff[stuff.length-1];
  
      for (int x = stuff.length-1; x &gt; position; x--) 
          list[x] = list[x-1];
  
      stuff[position] = y;
  }
  </code></pre>
  
  <p>edit: sorry I don't think I was clear enough. What I want to be able to do is given this method, I should be able to move the last piece anywhere. </p>
  
  <pre><code>for (int pos = 0; pos &lt; stuff.length; pos++)
  {
      moveLastup(list,pos);
      showList(list);
  }
  </code></pre>
  
  <p>Now when I execute this, it simply takes the last item in the next list in the for loop
  ex)</p>
  
  <pre><code>e,a,b,c,d
  
  e,d,a,b,c
  
  e,d,c,b,a
  </code></pre>
  
  <p>i would like it to show</p>
  
  <pre><code>e,a,b,c,d
  
  a,e,b,c,d
  
  a,b,e,c,d
  </code></pre>