title: change values in a 2-dimension array in java
body: <p>Iam trying to create a java program in which, i will be able to change the position of value 1 to specific positions into an array.For example i have the value 1 in the position [5][4] and i want to move it to the next (or the previews position) and delete the value 1 and store the value 0 into the previous position. My problem is that i can move the value 1 but i can't delete it from the previous position(store to the previous position the value 0).My code is the following:</p>
  
  <pre><code>for (int row = 0; row &lt; 6; row++) {
      for (int col = 0; col &lt; 6; col++) {
          int randomPosition = r.nextInt(2);
  
          array[row][col] = 0;
          array[2][3] = 1;
          array[4][4] = 1;
  
          if (array[row][col] == 1) {
              array[row][col] = 0;
  
              if (randomPos == 0) {
                  array[row - 1][col] = 1;
  
              } else if (randomPos == 1) {
                  array[row][col - 1] = 1;
  
              } else if (randomPos == 2) {
                  array[row + 1][col + 1] = 1;
  
              }
          }
      }
  }
  
  for (int row = 0; row &lt; cells.length; row++) {
      for (int col = 0; col &lt; cells[row].length; col++) {
          System.out.print("  " + cells[row][col]);
      }
  }
  </code></pre>