title: Shift one rows in a 2D Array in Java
body: <p>I am trying to make a game called Numbrosia for my computer science lab. It has to be a 5x5 board but when I try to shift the values within the rows either to the right or left some of my columns disappears.</p>
  
  <p>The array's values are</p>
  
  <pre><code> 1 -2  1  0  0
  -1  0  4  2  0
   0 -4  1 -1  0
   0  1 -1 -1 -2
   0 -3  1 -1  0
  </code></pre>
  
  <p>But I am getting</p>
  
  <pre><code>0 0 1 -2 
  0 2 4 0 
  0 -1 1 -4 
  0 -1 -1 1 
  0 -1 1 -3 
  </code></pre>
  
  <p>I will put my piece of code of the method that shifts it to the right</p>
  
  <pre><code>public public static void RowRight(int i, int[][] array){
     for(int row = 0; row &lt; array.length; row++){
         int temp = array[i][array.length-1];
         for(int col = array.length-2; col &gt; 0; col--){
             array [row][col+1] = array[row][col];
             System.out.print(array[row][col] + " ");
         }
         System.out.println("");
     }
  }      
  </code></pre>
  
  <p>I await someone's response thank you</p>
  
  <p>----------UPDATE-----------------------------</p>
  
  <p>I've managed to print the 5 columns but a new problem surfaced. Either if I shift the values in the row to the left or to the right, the position next to either the last number(that when shifting left was the first number) or the first number(when shifting right was the last number) has the same exact number as either the first or last.
  I'll put the outputs</p>
  
  <p>again the array values are </p>
  
  <pre><code> 1 -2  1  0  0
  -1  0  4  2  0
   0 -4  1 -1  0
   0  1 -1 -1 -2
   0 -3  1 -1  0
  </code></pre>
  
  <p>and I need to get for example the first row to move to the left, so it should print</p>
  
  <pre><code>-2  1  0  0  1
  -1  0  4  2  0
   0 -4  1 -1  0
   0  1 -1 -1 -2
   0 -3  1 -1  0
  </code></pre>
  
  <p>but I am getting this</p>
  
  <pre><code>-2  1  0  1  1
  -1  0  4  2  0
   0 -4  1 -1  0
   0  1 -1 -1 -2
   0 -3  1 -1  0
  </code></pre>
  
  <p>How can I solve this?</p>